猿问

一道acm的题,看了半天,不理解题意,求解释~

Problem Description
As a student in computer science, Ant is weak in Graph Theory learning. One day, he comes across a problem. Given a non-directed graph G which is donated by G = {V, E}. V is the set of vertexes and E is the set of undirected edges. You should select some vertexes as key vertexes and each edge should be connected by at least one key vertex. Ant sometimes can select the key vertexes as described above. But now he wants to select least vertexes as key vertexes. Here comes your question, given a graph and tell Ant how many ways are there to select least key vertexes.

Input
The first line of the input contains an integer T which is the number of test case, and then there are T groups of data following. For each group of data, the first line contains two integers. The first integer n is the number of vertexes and the second integer m is the number of edges. The next following m lines describe the edges. Each line contains two integers u, v which indicates there is an undirected edge connected vertex u and vertex v. (0 < n ≤ 20, 0 < m ≤ 300, u ≠ v, 1 ≤ u, v ≤ n)

Output
For each test case, output an integer which is the number of ways that selecting least key vertexes.

Sample Input
1
4 3
1 2
2 3
3 4

Sample Output
3

Hint

For the sample, there are three ways, which are selecting {1, 3}, {2, 4}, {2, 3}

慕尼黑5688855
浏览 658回答 2
2回答

一只名叫tom的猫

不知道你是不懂英文还是不懂题目。无向图什么的基础概念就不说了。题目中给出了“关键结点”(key vertex)这个概念,就是你要选择若干个关键结点,这样所有结点都跟关键结点连起来(至少有一条边)。例子中的图: 1  ---  2           | 4  ---  3 可以看到有3条边4个点。现在需要你的程序去选择关键点。例如例子中给出的答案:选择1和3作为关键点,这样其余结点(2和4)都至少跟1个关键结点相连(2根1、3相连,4跟3相连)。 也可以选择2和4作为关键点,也可以选择2和3.一共有3种选择方法(这就是程序要的输出)。并且要求关键点是最少的,如果4个结点都是关键点,毫无疑问肯定符合其他要求,但是无法符合最少关键点的要求。

慕标琳琳

算出一共有多少种可能的关键点集合,使得任意关键点集合可以覆盖图中的所有边。
随时随地看视频慕课网APP

相关分类

Java
我要回答