Euler's path and Euler's circuit Summary

Source: Internet
Author: User
Euler's path and Euler's circuit Summary

I will make a small summary of the Euler's and Euler's circuits, including some questions. I will add new ones in the future.

Definition: GivenNo isolated node DiagramG. If there is a path, each side of G has one and only one path. This path is Euler's.Path. If yes

A circuit passes through each edge of G and has only one time. This circuit is called the Euler loop. A diagram with Euler's loop is called the European Union.

For more information about the definition and existence proof of Euler's and Euler's circuits, see here. Here is the conclusion that there are conditions for the Euler's and Euler's circuits:

ExistEuler's RoadConditions:

Undirected graph: Graph connectivity. All vertices are even degrees, or only two vertices are odd degrees. When all vertices are even degrees, the Euler's path start point can be arbitrary.

Point. When there are two odd-degree points, the start point must be an odd-degree point.

Directed Graph: Graph connectivity. All vertices have an inbound degree, or one vertex has an inbound degree-outbound degree = 1, and one vertex has an inbound degree = 1. Similarly, when all vertices

The outbound value = the inbound value can be used as the starting point. The latter must start with the outbound value-Inbound value = 1, and the inbound value-outbound value = 1.

ExistEuler LoopConditions:

Undirected graph: Graph connectivity, where all vertices are even

Directed Graph: Graph connectivity. All vertices are equal to inbound.

Hybrid graph: Construct a network flow model for judgment. The details are as follows:

First, the undirected edge in the source image is oriented randomly, and then the outbound and inbound degrees of each vertex are calculated. If yes | outbound-Inbound | an odd number of vertices

There is no Euler Loop (because the Euler Loop requires that each vertex exit degree = inbound level, and does not affect the point of random orientation of undirected graphs | outbound degree-Inbound degree |

So if such a point exists, it is impossible to find the Euler Loop in any case. Otherwise, for each point,

Find its | outbound-Inbound |/2, and obtain X. Then start to construct the network: how to direct the undirected edge in the source image, and how to connect the edge in the network,

The capacity is 1. For each vertex, if (outbound-Inbound) is greater than 0, the Source Vertex is connected to the edge, and the capacity is X. If (outbound-Inbound) greater than 0,

Connect the edge to the sink point with the capacity of X. Then, find the maximum stream for the network. If the stream can be full, the original image will have an Euler loop; otherwise, it will not be saved.

In.

Proof: the difference between the outbound and inbound degrees of each vertex | outbound-Inbound |, which needs to be changedHalf, That is, the side connecting X to adjust it

Degree = inbound (Because changing one side changes the difference between the two sides.); For a vertex with an outbound degree greater than the inbound level and a Source Vertex's edge, equivalent

These vertices provide outbound. For vertices whose inbound degree is greater than the outbound level, the connected edge of the sink point is equivalent to the acceptable outbound level.

Direction: The capacity is 1, indicating that they can change the direction. If the stream is full, you can adjust the undirected edge to obtain the euro

When the traffic is 1, the direction of an edge is changed. How can we get the Euler's loop of this graph? We know, stream

1 indicates that the direction needs to be changed. Therefore, the final Euler loop is the Euler Loop of graph G.Directed source Image

Edge+Edge with Zero traffic in the Network+NetworkTraffic in the network is 1The reverse of the edge.

The proof of these conclusions is not difficult. You should think about why, which is very helpful for solving the problem.

Questions about this part of knowledge mainly include the following categories: one stroke problem (hdu3018); problems with Euler's path and Euler's loop

(Poj2513, poj1386, poj1637); Find An Euler's path and Euler's circuit problem (hdu2894, poj2230, poj2337,

Poj1392, poj1041), sometimes the minimum Lexicographic Order is required. Among them, model establishment and composition are the most important.


Given an undirected graph G, hdu3018 ant trip requires at least a few strokes.

Solution: For each connected component, if all vertices are even degrees, a stroke (that is, the Euler loop) is required. Otherwise, an odd number of vertices is required.

1/2. Ignore isolated points. It's easy to prove. Think about it yourself ~

Poj2513 colored sticks gives n sticks (n <250,000), each of which has two colors.

If the endpoint color is the same, it can be connected. Can I connect n sticks to one?

Solution: It is very bare to determine the problem of Euler's path. It is good to judge the degree of connectivity and point. Note that map cannot be used, and trie is required.

Poj1386 play on words: given n words, I asked if they can be arranged in a row according to the rules. Only when the two words IFF have the same endpoint can they be placed together.

For example, ACM, go, and micolog can be arranged in a column according to ACM-> micolog-> go.

Solution: this is an old question, which has been mentioned in the OI paper. The diagram is a bright spot. We regard words as edges and take the first and last characters

As a vertex edge. For example, ACM connects a and c, and then only needs to judge whether there is Euler's path.

Proof: A directed graph with n edges can be obtained by using N words in the preceding figure. If this graph has Euler's path, as shown in the preceding example,

If a-> M-> G exists, we can know that the words starting with a and ending with m are the first in the arrangement, and the words starting with M and ending with G are the second.

And so on. Therefore, this diagram is reasonable. If we make a word into a vertex, the question means to seek Hamilton's path,

It is obviously not as simple and intuitive as this.

Poj1637 sightseeing tour refers to the Euler loop of the raw hybrid graph to determine whether it exists. You can construct a network based on the method mentioned above to determine whether the network is full.

Hdu2894 debruijinDebruijinGraph problem. Given a number N, find a 01 string with a length of 2 ^ N, so that any n substrings represent 0

2 ^ The number of all N-1 happens exactly once and requires the smallest Lexicographic Order.

Solution: directly search for DFS. Find the unmarked number in the order of adding 0 and then 1, mark the number, and then output the result in reverse order.

Poj2230 watchcow provides an undirected graph, which ensures that there is an Euler path, finding an Euler path and the access sequence of the output points.

Solution: directly use DFS. Because there is no requirement, you can directly output the results in the DFS process (in reverse order) without recording the results.

Poj1041 John's trip is given a directed graph. If there is an Euler's path, the access order of the output edge is obtained.

Solution: DFS, intermediate record results. Note that the order of the output edge is different from that of the output point.

Poj2337 catenyms has the same meaning as poj1386, but the final result must be output and the Lexicographic Order must be minimized.

Solution: Save the start point, end point, and corresponding words for each edge to determine whether the edge exists. If yes, sort all the edges according to the word.

And then DFS + backtrack to find the Euler path. For details, seeCode.

Poj1392 Ouroboros snake and hdu2894 have almost the same question. Give n k and find the k Number of the string when the length is N.

Solution: the DFS record is the same as hdu2894.

Hey, I can't turn it over. I just paste it. The original link is:

Http://www.orzminjie.info /? P = 179001

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.