1、An Euler Circuit is a cycle of an undirected graph, that traverses every edge of the graph exactly once, and ends at the same node from which it began. Eulers Theorem: A connected graph G possesses an Euler circuit if and only if G does not contain any nodes of odd degree.Proof of Eulers theorem: As
2、sume that G has zero nodes of odd degree. It can then be shown that this is a necessary and a sufficient condition for an Euler circuit to exist. Part 1: It is necessary because any Euler circuit drawn on the graph must always enter a node through some edge and leave through another and all edges on
3、 the graph must be used exactly once. Thus, an even number of incident edges is required for every node on the graph.,Proof of Eulers theorem Part 2: Sufficiency, on the other hand, can be shown through the following tour construction argument. We begin at some initial node k0 and draw a circuit thr
4、ough G (thus eventually returning to k0). Let this circuit be denoted C0. If C0 happens to be an Euler circuit, this is fine; we stop. If C0 is not an Euler circuit, then if we remove from G all edges used by circuit C0, there must be some edges left over. Moreover, at least two of these edges must
5、be incident on some node k1 through which circuit C0 has passed. This must be so since, by assumption, G is, first, connected and, second, all its nodes are of even degree (and C0 has only used up an even number of edges which are incident on k1). Thus, it is possible to draw another circuit C1 orig
6、inating and terminating at k1, which uses only edges of G, the graph left after we eliminate the edges of C0 from G. This procedure may now be continued until eventually, say after the nth step, there will be no edges left uncovered. At that time, an Euler circuit will also have been obtained which
7、will be a combination of circuits C0, C1, C2, . . ., Cn.,Eulers theorem is a proof by construction. However, the algorithm could be O(E2) or O(E log E) where E is the number of edges in the graph.Note: both of these are O(E2):,for i = 1 to n for k = 1 to n ,for i = 1 to n for i = 1 to n . . (linear
8、function of n times) . for i = 1 to n ,Pick any vertex to start. From that vertex pick an edge to traverse, considering following rule: never cross a bridge of the reduced graph unless there is no other choice. Darken that edge, as a reminder that you cant traverse it again. Travel that edge, coming
9、 to the next vertex. Repeat 2-4 until all edges have been traversed, and you are back at the starting vertex.By reduced graph we mean the original graph minus the darkened (already used) edges.A bridge of a graph G is an edge whose deletion increases the number of components of G.,Fleurys Algorithm:
10、 O(E)?,Fleurys Algorithm in Action,Pick any vertex (e.g. F) Take F to C (arbitrary),Take C to D (arbitrary),Take D to A (arbitrary),Take A to C. Cant go to B: that edge is a bridge of the reduced graph, and there are two other choices.,How can we recognize a bridge efficiently? In the original graph
11、, AB was not a bridge. Can we preprocess the graph in O(E) time identifying bridges and building a structure that can be updated in constant time with each reduction?,A bridge is not a local property (i.e. if edge EF existed then AB would not be a bridge).,Scrub Tile Puzzle A Hamiltonian Cycle,Puzzl
12、e Applet,Given 10 equally sized index cards each with one of the following words: HEN, HUT, WIT, SAW, CAR, CUB, MOB, DIM, RED, SON. Arrange the cards in a rectangular closed chain such that any two adjacent words must share a common letter.,The above may serve to demonstrate a possible arrangement.
13、However, the words SON and RED, although adjacent, do not have a letter in common. Therefore, its not a valid configuration. Repeat the same problem with the cards SON and HUT replaced by SUN and HOT.,Scrub Tile Puzzle,Of the two variants of the puzzle, the second is solvable, the first is not. The
14、two variants are represented by different graphs. A solution to the puzzle constitutes a Hamiltonian circuit on its graph. The first of the two is the famous Petersen graph that is known not to house any Hamiltonian circuits.,Dodecahedral Graph Is it Hamiltonian? If so, find the Hamiltonian Cycle,Kn
15、ights Tour Problem,The “Knights Tour“ is a sequence of moves done by a knight on a chessboard. The knight is placed on an empty chessboard and, following the rules of chess, must visit each square exactly once. There are several billion solutions to the problem, of which about 122,000,000 have the k
16、night finishing on a square which is just a move away from the starting square. Such a tour is described as “closed”.The Knights Tour problem is an instance of the more general Hamiltonian path problem in graph theory. The problem of getting a closed Knights Tour is similarly an instance of the Hami
17、ltonian cycle problem.,Find a Closed Knights Tour,State as Hamiltonian Path Problem,For a given n value, find an arrangement of the first n natural values such that, at the same time: The sum of every two adjacent numbers is a prime. The sum of every two adjacent squares is a prime.Find such a sequence for n = 10.,
copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1