Vaša košarica je prazna
GRAPHS– path, trail, walk, cycle, Eulerian trail (extra-curricular topic)
Example 1
In the \latex{ 18 }th century there were seven bridges over the river of Pregel across the city of Königsberg according to Figure 25.
- The citizens of the city liked walking on Sundays, and they came up with the question whether it was possible for someone to walk over every bridge starting from home and then arriving back home again so that not to walk over any bridge more than once. They turned to Euler with this problem, who was a teacher at the academy of Saint Petersburg at that time.
- Is there a part of the city starting from where we can tour all the bridges so that we walk over each of them exactly once but we do not necessarily have to arrive back to the starting place?
- How many bridges should be built at least and where should these be built so that there will be a part of the city starting from where we can tour all the bridges so that we walk over each of them exactly once but we do not necessarily have to arrive back to the starting place?
- How many bridges should be built at least and where should these be built so that there will be a part of the city starting from where we can tour all the bridges so that we walk over each of them exactly once and we arrive back to the starting place?
Solution (a)
Let us try the tour corresponding to the example. The failure of the many trials does not mean that the example cannot be solved; it only means that we have not managed yet with these methods. In order to be able to say that the example does not have a solution we should check all the possible tours, which in general means very many cases, therefore it is practical to search for another method.
Let the parts of the city denoted by \latex{ A,\, B,\, C,\, D } be represented by a point each, and a bridge between two parts of the city be represented by an edge connecting the corresponding points. If the suitable path exists, then the following should hold:
- If we start from a part of the city, we also have to get back there; it means two distinct bridges (edges) that start from that part of the city
- If we pass through a part of the city, then we arrive there through one bridge and we also have to leave on another one, thus it also means two distinct bridges (edges) that start from that part of the city (point).
Based on these only such a path network can be toured – so that we walk along every edge exactly once and we get back to the starting point in which even number of edges start from every point, i.e. the degree of every point is even. We wrote the degrees of the points next to them,so it can be seen that there are even four points the degree of which is odd, thus the bridges cannot be toured so that we walk through every bridge exactly once and we get back to the starting point. (Figure 26)
So the degree of every point being even is a necessary condition of a graph being able to be toured so that we walk along every edge exactly once and we get back to the starting point.
Solution (b)
Let us consider the part of the city where we start from and the one where we will arrive in the end. If these are not the same, then the number of the bridges starting from them needs to be odd, since leaving and arriving mean one bridge each, and on top of that every leaving and arriving can happen through even number of bridges. So the degree of the points corresponding to these two parts of the city (the one we start from and the one where we arrive in the end) is odd.
The degrees of the other points of the path are even just like before, since as many times we arrive at a point on an edge we also have to leave that point on another edge.
The degrees of the other points of the path are even just like before, since as many times we arrive at a point on an edge we also have to leave that point on another edge.
So if we were able to tour the bridges so that we walked through every bridge exactly once but we did not get back to the part of the city where we had started from, then there would be two parts of the city with odd number of bridges starting from and even number of bridges would start from the other parts of the city. As now there are four parts of the city with odd number of bridges starting from, the bridges cannot be toured so that we walk through each of them exactly once even if we do not have to get back to the starting place.
So the degrees of the starting point and the end-point being odd and the degrees of all the other points being even are necessary conditions of a graph being able to be toured so that we walk along every edge exactly once and the starting point and the end-point of the path are distinct.
So the degrees of the starting point and the end-point being odd and the degrees of all the other points being even are necessary conditions of a graph being able to be toured so that we walk along every edge exactly once and the starting point and the end-point of the path are distinct.
Solution (c)
One bridge should definitely be built so that the necessary condition found in the previous part is satisfied. It can be built between any two parts of the city with odd number of bridges starting from.
Two possibilities and suitable tours belonging to each of them can be seen in Figures 27 to 28. One bridge is actually enough, and we verified it by showing a possible tour for each.

Figure 27
The tour is:
\latex{ CABCDBDAB }
\latex{ CABCDBDAB }
\latex{ C }
\latex{ A }
\latex{ B }
\latex{ D }

Figure 28
The tour is:
\latex{ ABDBCBACD }
\latex{ ABDBCBACD }
\latex{ A }
\latex{ B }
\latex{ D }
\latex{ C }
Solution (d)
Two bridges should definitely be built so that the necessary condition found in part a) is satisfied, since a pair of two parts of the city should be connected with a bridge from which only odd number of bridges started from at the beginning. Two possibilities and suitable tours belonging to each of them are shown in Figures 29 to 30. So two bridges are actually enough, and we verified it by showing a possible tour for each.

Figure 29
The tour is:
\latex{ DCBCABADBD }
\latex{ DCBCABADBD }
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }

Figure 30
The tour is:
\latex{ DCDBCABABD }
\latex{ DCDBCABABD }
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }
DEFINITION: A walk is a sequence of adjacent edges of the graph, and in this sequence the same edges and points are allowed to occur more than once.
Example: We can see trails leading from part \latex{ A } to part \latex{ D } of the city of Königsberg in the Figures 31 to 32.

Figure 31
The tour is:
\latex{ ABACBACD }
\latex{ ABACBACD }
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }

Figure 32
The tour is:
\latex{ ABCABD }
\latex{ ABCABD }
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }
DEFINITION: A trail is a sequence of adjacent edges of the graph, and in this sequence every edge can occur at most once, but there can be points that occur more than once.
Example: We can see trails leading from part \latex{ A } to part \latex{ D } of the city of Königsberg in the Figures 33 to 34.

Figure 33
The tour is:
\latex{ ABACBD }
\latex{ ABACBD }
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }

Figure 34
The tour is:
\latex{ ABCABD }
\latex{ ABCABD }
\latex{ B }
\latex{ A }
\latex{ D }
\latex{ C }
DEFINITION: A path is a sequence of adjacent edges of the graph that does not pass through any point more than once.
Example: We can see paths leading from part \latex{ A } to part \latex{ B } of the city of Königsberg in the Figures 35 to 36.

Figure 35
The tour is:
\latex{ ABD }
\latex{ ABD }
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }

Figure 36
The tour is:
\latex{ ACBD }
\latex{ ACBD }
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }
DEFINITION: A cycle is a sequence of adjacent edges of the graph, and in this sequence the starting point is the same as the end-point, and every edge and all the other points occur at most once.
Example: We can see cycles in the city of Königsberg in the Figures 37 to 38.

Figure 37
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }

Figure 38
\latex{ A }
\latex{ D }
\latex{ B }
\latex{ C }
DEFINITION: A graph is called a connected graph, if there is a path from any of its points to any of its points. The connected parts of a non-connected graph are called components.
Example: A connected graph can be seen in Figure 39. Figure 40 shows a non-connected graph consisting of three components.

Figure 39

Figure 40
DEFINITION: A trail in a graph is called an Eulerian trail, if it passes through every edge of the graph. An Eulerian trail can be open, if its starting point is different from its end-point, or it can be closed, if its starting point is the same as its end-point.
Based on example \latex{ 1 } we can formulate the following theorem:
THEOREM: The degree of every point being even in a graph is a necessary condition for the existence of a closed Eulerian trail.
The degrees of two points being odd and the degrees of the other points being even in a graph is a necessary condition for the existence of an open Eulerian trail.
The theorem can be proven based on part a) and b) of example \latex{ 1 }.
Another necessary condition for the existence of an Eulerian trail is that we can get from the end-points of any edge to the end-points of any edge along edges in the graph.
Another necessary condition for the existence of an Eulerian trail is that we can get from the end-points of any edge to the end-points of any edge along edges in the graph.
It is satisfied if the graph is connected, or if it is not connected, then besides one component all the other components are isolated points (Figure 41). So the graph being connected and the degree of every point being even are necessary conditions for the existence of a closed Eulerian trail in a graph not containing any isolated points.
The graph being connected and the degrees of two points being odd and the degrees of all the other points being even are necessary conditions for the existence of an open Eulerian trail in a graph not containing any isolated points.
These conditions are also sufficient.
These conditions are also sufficient.
THEOREM: If in a connected graph the degree of every point is even, then there is a closed Eulerian trail in the graph.
Proof
Let us consider a connected graph in which the degree of every point is even. Weare going to show that there is a closed Eulerian trail in it. The proof is constructive; it also gives a method for finding an Eulerian trail.
Tour algorithm
Let us start from an arbitrary point \latex{ A } of the graph on an arbitrary edge, and let us number the edges in the order corresponding to the tour. If we can get to a point, then we can surely carry on from there on an edge different from the previously toured ones, as its degree is even, thus the only point, where we can get stuck, is the point \latex{ A }. It can happen that we have not toured every edge yet; in this case the trail obtained can be expanded. As the graph is connected, among the edges not toured yet there must be one incident at a point toured; let us denote this point by \latex{ B }. Let us start from \latex{ B } on edges not toured yet, then the only point, where we can get stuck, is the point \latex{ B }. Let us renumber the edges toured so that we keep the previous numbering up to \latex{ B }, then we continue the numbering on the edges toured this time, until we get back to \latex{ B }, then on the edges toured previously to \latex{ A }. Thus an expanded trail is obtained that contains every edge at most once (Figure 42).
This expanding process can be continued as long as there is an edge not toured yet. The number of the edges is finite, thus a closed Eulerian trail is obtained with this process.
THEOREM: If in a connected graph the degrees of two points are odd, and the degrees of the otherpoints are even, then there is an open Eulerian trail in the graph.
Proof
By connecting the two points with odd degree with an edge the degree of every point becomes even, thus we can find a closed Eulerian trail based on the previous. If we leave away the edge just drawn, an open Eulerian trail is obtained. Based on these the following are true:
THEOREM: In a graph not containing any isolated points there is a closed Eulerian trail if and only if the graph is connected and the degree of every point is even.
THEOREM: In a graph not containing any isolated points there is an open Eulerian trail if and only if the graph is connected, the degree of two points is odd and the degree of the other points is even.
Example 2
- Let us find a path between the points \latex{ A } and \latex{ I } in the graph in Figure 43;
- Let us find a trail between the points \latex{ A } and \latex{ I } that is not a path. Let us find a path the edges of which also occur among the edges of the trail;
- Let us find a walk between the points \latex{ A } and \latex{ I } that is not a trail. Let us find a trail the edges of which occur among the edges of the walk;
- Let us find a cycle. Is it true that by leaving away an arbitrary edge of a cycle the graph stays connected?
- Let us find two distinct paths between the points \latex{ A } and \latex{ I }
Solution (a)
The order of the points on a possible path is: \latex{ ADFGI }. (Figure 44)
Solution (b)
The order of the points on a possible trail is: \latex{ ADBCEDFGI }. (Figure 45)
This trail is not a path, because the point \latex{ D } occurs several times on the trail. If we leave away the part of the trail between the first and the last occurrence of \latex{ D }, then the point \latex{ D } occurs on the trail only once. Thus the path \latex{ ADFGI } leading from \latex{ A } to \latex{ I } is obtained.
Every path is also a trail.
THEOREM: If there is a trail between two points of a graph, then there is also a path.
Solution (c)
The order of the points in a possible walk is: \latex{ ADFECDFGI }. (Figure 46)
This walk is not a trail, because the edge \latex{ DF } occurs several times. If we leave away the part of the walk between the two occurrences of the edge \latex{ DF }, and the edge \latex{ FG } comes after the edge \latex{ DF }, then the edge \latex{ DF } occurs only once in the walk. After this there are no more edges that occurred several times, so the walk \latex{ ADFGI } is a trail.
This walk is not a trail, because the edge \latex{ DF } occurs several times. If we leave away the part of the walk between the two occurrences of the edge \latex{ DF }, and the edge \latex{ FG } comes after the edge \latex{ DF }, then the edge \latex{ DF } occurs only once in the walk. After this there are no more edges that occurred several times, so the walk \latex{ ADFGI } is a trail.
Every trail is also a walk.
THEOREM: If there is a walk between two points of a graph, then there is also a trail.
Solution (d)
A cycle in the graph is for example as follows: \latex{ ABCEFDA }. (Figure 47)
By leaving away any edge of the cycle (e.g. \latex{ AD }), the two end-points of the edge divide the cycle into two paths (paths \latex{ AD } and \latex{ ABCEFD }). Then we write the path \latex{ ABCEFD } instead of the edge \latex{ AD } in the path between two arbitrary points of the graph, thus a walk is obtained between the two points, and if there is a walk between two points, then there is also a path; so the graph stays connected, if we leave away an arbitrary edge of a cycle.
By leaving away any edge of the cycle (e.g. \latex{ AD }), the two end-points of the edge divide the cycle into two paths (paths \latex{ AD } and \latex{ ABCEFD }). Then we write the path \latex{ ABCEFD } instead of the edge \latex{ AD } in the path between two arbitrary points of the graph, thus a walk is obtained between the two points, and if there is a walk between two points, then there is also a path; so the graph stays connected, if we leave away an arbitrary edge of a cycle.
THEOREM: If we leave away an arbitrary edge of a cycle in a connected graph, the graph stays connected.
THEOREM: If there is a cycle in a graph, then it has two points, which are connected by two distinct paths.
Solution (e)
Two distinct paths between the points \latex{ A } and \latex{ I } are for example (Figure 48): \latex{ ADFGI } and \latex{ ADFEHGI }. By considering the two distinct paths it can be seen that there is a cycle in the graph.
THEOREM: If a graph has two points, which are connected by two distinct paths, then there is a cycle in the graph.
The statements highlighted during the solution of the example can be proved with the help of the generalisation of the solution; these proofs are not detailed here.
Example 3
Twelve boys correspond. Every boy is in communication with at least two other boys. One of them sends news to one of his acquaintances. That boy also sends it to one of his acquaintances, but not to the one he received it from. The boys do not get news from other sources.
- Will everyone have got the news for sure before it gets back to a boy who had heard of it already?
- Is it true that the news will get back to a boy for sure who had heard of it already?
- At least how many boys will get the news?
Solution (a)
It is possible that not everyone will have got the news before it gets back to someone who had heard of it already. It means that it is not sure that the cycle in the graph passes through every point. (Figure 49)
Solution (b)
Everyone can pass along the news, as he has at least two acquaintances: he gets it from one of them and he passes it along to the other one.
As the number of the boys is finite, it will surely get back to someone who had heard of it already. It means that there is a cycle in the graph in which the points (vertices) represent the boys and the lines (edges) connecting the points represent the transmission of the news.
Solution (c)
The second boy, who heard of the news, needs to pass it along to a third one, so three boys will surely know about it.
Figure 50 shows that it is possible that only three boys know about it.
The following theorem can be proven similarly to the solution of the example:
The following theorem can be proven similarly to the solution of the example:
THEOREM: If in a connected finite graph the degree of every point is at least two, then there is a cycle in the graph.
Consequence: If there is no cycle in a connected graph, then it has a point of degree one.
Proof of the consequence
The graph is connected, thus it does not have a point of degree zero. If the graph did not have a point of degree one, then the degree of every point would be at least two, thus because of the theorem there would be a cycle in it. However there is no cycle in the graph, therefore it has a point of degree one.

Exercises
{{exercise_number}}. Which of the following figures can and which cannot be drawn without lifting our pencil, so that we do not trace any line segment more than once? Why?

\latex{ b })
\latex{ a })
\latex{ c })
{{exercise_number}}. The streets of the part of the city highlighted in orange on the map are sprinkled by a water sprinkler vehicle in the evening of a hot summer day. Is it possible that the water sprinkler vehicle passes along every street but none of the streets has a part where it passes along more than once?

{{exercise_number}}. A burglar was caught in the bank the plan of which can be seen in the figure. The burglar was nicked while opening the safe, and – with the help of the security system – it was established that by the time he got there he had stepped through every door exactly once. In which room is the safe?

\latex{ A }
\latex{ B }
\latex{ C }
\latex{ F }
\latex{ E }
\latex{ D }
\latex{ G }
\latex{ H }
\latex{ I }
{{exercise_number}}.
- Can the figure be drawn without lifting the pencil so that none of the line segments is traced more than once?
- At least how many times shall we lift the pencil and carry on with drawing from another point to draw the figure so that none of the line segments is traced more than once?
- Is there a curve that intersects every line segment in the figure at exactly one point (the curve should not touch the line segments)?

{{exercise_number}}. The figure shows the road network between nine villages; the numbers written on the roads represent the distance between the villages in kilometres. The status of the roads is checked, therefore a car drives on every road starting from village \latex{ A }. Which route should be chosen so that all the stages are checked and it gets back to \latex{ A } on the shortest possible path?

\latex{ G }
\latex{ A }
\latex{ D }
\latex{ I }
\latex{ H }
\latex{ C }
\latex{ E }
\latex{ F }
\latex{ B }
\latex{ 13 }
\latex{ 12 }
\latex{ 12 }
\latex{ 13 }
\latex{ 5 }
\latex{ 13 }
\latex{ 12 }
\latex{ 12 }
\latex{ 12 }
\latex{ 12 }
\latex{ 12 }
\latex{ 5 }
\latex{ 13 }
\latex{ 13 }
\latex{ 13 }
\latex{ 5 }
\latex{ 12 }
\latex{ 12 }
{{exercise_number}}. We would like to create the framework of a cube with \latex{ 10\, cm } long sides by using a wire with a length of \latex{ 12\, dm }. We cut the wire at the least possible places, we bend it and then we solder it at the appropriate places. At how many places do we have to cut it?
{{exercise_number}}.
- At most how many edges of the graph of example \latex{ 2 } can be left away
- At least how many edges of the graph of example \latex{ 2 } should be left away so that there is no cycle in the graph and the graph still stays connected?
{{exercise_number}}. Which of the following statements are true and which are false? Justify your answer.
- If a graph is connected, then there is a walk leading from any of its points to any of its points.
- If there is a cycle in a graph, then the graph is connected.
- If there is a closed Eulerian trail in a connected graph, then there is a point in the graph that can be left away with the graph staying connected.
- If a graph is connected, then there is an edge that can be left away with the graph staying connected.












