13.1-Graph-theory1
13.1-Graph-theory1
CONTENTS
• Graph Theory Definition
• The three types of Graphs
2
Graph theory:
Is the formal study of a symbolic representation, based on the connectivity of vertices and edges.
(concerns the relationship among lines and points)
3
There are three types of graphs:
Undirected Directed Mixed graphs
• Undirected: if the shake hands, if a person A shake hands with a person B, then person B also shook hand with
person A.
• Directed: if one person knows another, does not necessarily implies the reverse (one person is famous).
Degree of a vertex is the number of edges incident to it. Exercise 1
3+4+4+4+2+4=20
5
Exercise 2
a) Can you draw a graph with the sum of degree of vertices to be an odd number?
Handshaking Theorem
Since every edge connect two vertices one for each of its end points, the total sum of degree of vertices must
be twice the sum of the edges.
sum of degree of vertices
Sum of edges =
2
Conclusions:
• Sum of degree of vertices must be an even number.
a) In an octagon, what is the sum of its edges, if we draw all of its diagonal?
b) Write down the general formula for the number of sides of a closed polygon if we join all its vertices.
Games for connected graphs
The key insight is that except for the starting and ending vertices, the path you are following must go through a
vertex along one edge and then out of the same vertex along a different edge. Such a process always uses up two of
the edges which derive from the vertex. We may go through the same vertex again any number of times, but each
time we are eliminating exactly two edges. Thus each vertex which is not the starting or ending point has an even
number of edges coming out of it.
The starting and ending vertices, will be the only two vertices which must have an odd degree.
Therefore, a Eulerian path always exist if there are exactly two odd vertices, and an
Eulerian path will always start and and end on the odd degree vertices.
Exercise 4
4 4
3 3
b) For those graph that there exist a Eulerian path find it.
Eulerian Circuit
Eulerian circuit is a Eulerian path which starts and ends on the same vertex.
Based on observation we found from the Eulerian Path, if we want to end back on the same vertex, we need to
add an edge between the two odd vertices. But since adding this edge increases the degree of each by 1, their
degrees are then even.
Therefore, a Eulerian circuit always exist if all of its vertices are of even degree.
In other words, a Eulerian circuit always exist if there are not odd degree vertices.
Exercise 5
Try to always have a connected graph. In other words do not burn your bridge.
THE MINIMAL ROUTE FOR WEIGHTED NETWORKS
EULERIAN GRAPH
Graph 1
Distance between two vertices: The total length of an edge ( Distance of edge ΑΒ = 11 and ΑΒ=ΒΑ)
14
Graph 1
The total distance in Graph 1 is 11+7+8+12+9+10 = 57. Notice that the shortest route will be equal to the
weight of the network
Notes: 1) It is possible to choose any vertex to be the starting or the ending point of the route.
2) For Weighted Eulerian graphs the weight of the network is always equal to the minimal route
since the total distance is the same independently of the order we move from one vertex to another.
15
SEMI-EULERIAN GRAPHS
Graph 2
Notice that: 1) Vertices T and Q have odd valency (3) and all the remaining vertices have even degree.
Task 2: Find the minimal route for Graph 2 that traverses each edge only once.
It is permitted to start and finish at different vertices
One solution : TRQST U S P Q Minimal route: 37
Comments: 1) We can find a solution to the above problem only if the starting and the ending points are the two
vertices with odd degree.
2) The only way to find a route in this network by starting from a vertex of an even degree is by
16
traverse an edge (or edges) at least twice. Therefore the total weight of the route is increased.
Graph 2
Task 3: Find a minimal route, starting and finishing at S, that traverses each edge at least once.
State your route and its length.
How to solve: The odd degrees are at vertices Q and T. We have to repeat the shortest path Q to T,
which is Q S T, of length 9.
(Transforming the graph from semi – Eulerian to Eulerian)
This algorithm can be used to find the shortest route that traverses every edge at least once and returns to the
starting point.
18
APPLYING THE ROUTE INSPECTION ALGORITHM IN NON EULERIAN GRAPHS
Graph 3
Question 6: Solve the route inspection problem for this network starting and finishing at A.
Using A as the starting and finishing point the length of the shortest route will be:
20
Planar graphs
When is it possible to draw a graph so that none of the edges cross? If this is possible,
we say the graph is planar (since you can draw it on the plane).
When a planar graph is drawn without edges crossing, the edges and vertices of the graph divide
the plane into regions. We will call each region a face. The number of faces does not change no
matter how you draw the graph (as long as you do so without the edges crossing), so it makes
sense to ascribe the number of faces as a property of the planar graph.
A railway station have suggested that some of the rail lines, stations and/or trains should be eliminated to allow
the company to minimize its losses. A team of consultants has been hired to analyze the rail services that are
available in any region and decide where it needs to concentrate its money and services to best meet the needs
of its customers. As a team of consultants you will need to make recommendations in your area of expertise as
to what the company should do.
The first step is encouraging the students to visualize the data by drawing train routes. Discuss with them what it
means for cities to be connected. The mapped train routes can be transformed into formal graphs where vertices
are cities and edges are route segments that connect the cities
a. What are the major cities in the model? What makes a city important?
b. Are there some trains that are more important then others? How do you know that they are more important?
c. As consultants what are some (at least three) ways we could help Amtrak save money?
One problem with removing edges is deciding how many edges to remove and which ones they should be.
A minimum spanning tree will ensure that all cities are still connected to. When creating such a tree, there
are many factors that may be accounted for:
• Traffic on each train – Could be a factor of whether the route remains or to be removed.
• Cost of track-depending on the distance it covers. When there are multiple routes to a city, it
may be cheaper to eliminate the longer tracks.
• Travel time/distance: it may be important to take into account the travel time between any two
cities. It may be useful to calculate the maximum and average travel time/distance between all
pairs of cities in the graph.
Examples of graphs, where the numbers on each segment represents:
a) Distance
b) Time in hours
c) Frequency on each route
d) Cost in Euros
Algebra representation examples
Now that the students have an understanding of what the graph looks like and an understanding of what
the problem is and why it is important they are ready for the next part.
A local problem can be given, or they can use the one given.
Problem
Below is a list of all trains servicing the northeast, as well as the connecting cities.
b) Chose a path that can optimized the trains routes for connected cities.
c) Identify the most central cities based on their distances and place them in rank position.
(hint the city with the smallest distance to all the rest will be the most central)
d) Chose a path that can optimized the trains routes with respect of their distances.
For the Teacher-solutions
a)
c)
d) Since the idea is to use the least amount of track as
possible, one option is to create a minimal spanning tree.
Since the idea is to use the least amount of track as possible, one
option is to create a minimal spanning tree. There is now 1446
miles of track compared to 3378 miles of original track: