I have always wanted to write some ideas about graph theory learning. It has never been started for one reason or another. In any case, start now! So what is a graph? The figure we are talking about here is certainly not just like a picture. The most authoritative definition: Graph = vertex set + edge set. In other words, everything that can be abstracted into a set of points and an edge set is a graph. For example, map of China. The city on the map is a point, and there is a road between any two adjacent cities. A map is a very intuitive graph. To facilitate expression, we have introduced English words. Vertext (vertex), Edge (Edge), Graph ). You can use G <V, E> to represent any graph. A map is a map, and the seven water networks in China are also a map. Many lakes can be seen as vertices, while the Yangtze River and the Yellow River can be seen as edges. Because the flow of water is basically one-way (of course there is also a back-flow situation, we will ignore it here), so, like this: A directed graph is called a directed graph. The Yangtze River water flows only from the Himalayas to the East China Sea, but it never returns. If the edge has no direction, it is of course called an undirected graph. Let's go back to the map. All said things about great roads to Beijing. You said Rome is true.) How many roads are there in Beijing? In graph theory, the number of edges connected to a point, such as the number of edges connected to Beijing, is called degree! For all vertices in a graph, we can calculate the degree of each vertex. A string of numbers like this is called a degree sequence. In turn, can we determine if a sequence is sequential? Here is a theorem: Havel-Hakimi can be used to determine whether a sequence is complete. Poj1659 is solved by Havel-Hakimi.
The content of Havel-Hakimi theorem can be Baidu. Havel-Hakimi theorem is easy to understand: three steps: for example, sequence: 4 7 7 3 3 3 2 1
| Subscript |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
| Value |
4 |
7 |
7 |
3 |
3 |
3 |
2 |
1 |
Step 1: sort the sequence in descending order.
| Subscript |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
| Value |
7 |
7 |
4 |
3 |
3 |
3 |
2 |
1 |
Step 2: Delete the first number 7. Sequence Conversion
| Subscript |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
| Value |
7 |
4 |
3 |
3 |
3 |
2 |
1 |
Step 3: start from scratch, number 7, I .e. Subscript: [1, 7], reduce the values in the [1, 7] range by 1 because the first number has been deleted, then the sequence becomes like this:
| Subscript |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
| Value |
6 |
3 |
2 |
2 |
2 |
1 |
0 |
Then, repeat the first step: sort. Repeat Step 2: delete number 1 6 repeat Step 3: Number 6 from scratch: that is, subscript 1, 6], delete the number in range 1, 6. Sequence:
| Subscript |
1 |
2 |
3 |
4 |
5 |
6 |
| Value |
2 |
1 |
1 |
1 |
0 |
-1 |
Because-1 already exists, and the number of edges of a vertex) cannot be negative. Therefore, we can determine that a sequence cannot constitute a graph, so this sequence cannot be a graph. Here is another example: sorted:
Delete the first number 5:
Subtract 1 from the first five:
Sort:
Delete the first number 3:
Subtract 1 from the first three:
Sort:
Delete the first number 1:
Reduce the number of the first 1 to 1:
Sort:
Delete the first number 1:
Reduce the number of the first 1 to 1:
Sort:
So far, there are only:
It is determined that the sequence is sequential.
This article from the "every day progress a little" blog, please be sure to keep this source http://sbp810050504.blog.51cto.com/2799422/883904