


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A graph is a picture of dots called vertices and lines called edges. ... If there is a way to get from one vertex of a graph to all the other vertices of ...
Typology: Study notes
1 / 34
This page cannot be seen from the preview
Don't miss anything!
Graph theory deals with routing and network problems and if it is possible to find a “best” route, whether that means the least expensive, least amount of time or the least distance. Some examples of routing problems are routes covered by postal workers, UPS drivers, police officers, garbage disposal personnel, water meter readers, census takers, tour buses, etc. Some examples of network problems are telephone networks, railway systems, canals, roads, pipelines, and computer chips.
There are several definitions that are important to understand before delving into Graph Theory. They are:
Example 6.1.1: Graph Example 1
Figure 6.1.1: Graph 1
In the above graph, the vertices are U, V, W, and Z and the edges are UV, VV, VW, UW, WZ 1 , and WZ 2.
This is a connected graph. VV is a loop. WZ 1 , and WZ 2 are multiple edges.
Example 6.1.2: Graph Example 2
Figure 6.1.2: Graph 2 Figure 6.1.3: Graph 3
The graph in Figure 6.1.2 is connected while the graph in Figure 6.1.3 is disconnected.
Graph Concepts and Terminology:
Order of a Network: the number of vertices in the entire network or graph
Adjacent Vertices: two vertices that are connected by an edge
Adjacent Edges: two edges that share a common vertex
Degree of a Vertex: the number of edges at that vertex
Path: a sequence of vertices with each vertex adjacent to the next one that starts and ends at different vertices and travels over any edge only once Circuit: a path that starts and ends at the same vertex
Bridge: an edge such that if it were removed from a connected graph, the graph would become disconnected
Example 6.1.3: Graph Terminology
Figure 6.1.4: Graph 4
In the above graph the following is true:
Example 6.2.1: Spanning Subgraph
Figure 6.2.1: Map of Connecting Towns
This is a graph showing how six cities are linked by roads. This graph has many spanning subgraphs but two examples are shown below.
Figure 6.2.2: Spanning Subgraph 1
This graph spans all of the cities (vertices) of the original graph, but does not contain any circuits.
Figure 6.2.3: Spanning Subgraph 2
This graph spans all of the cities (vertices) of the original graph, but does not contain any circuits.
Tree: A tree is a graph that is connected and has no circuits. Therefore, a spanning subgraph is a tree and the examples of spanning subgraphs in Example 6.2.1 above are also trees.
Properties of Trees:
Example 6.2.2: Tree Properties
Figure 6.2.2: Spanning Subgraph 1
Consider the spanning subgraph highlighted in green shown in Figure 6.2.2.
a. Tree Property 1 Look at the vertices Appleville and Heavytown. Since the graph is a tree, there is only one path joining these two cities. Also, since there is only one path between any two cities on the whole graph, then the graph must be a tree.
b. Tree Property 2 Since the graph is a tree, notice that every edge of the graph is a bridge, which is an edge such that if it were removed the graph would become disconnected.
Example 6.2.4: Minimum Spanning Tree
Figure 6.2.5: Weighted Graph 1
The above is a weighted graph where the numbers on each edge represent the cost of each edge. We want to find the minimum spanning tree of this graph so that we can find a network that will reach all vertices for the least total cost.
Figure 6.2.6: Minimum Spanning Tree for Weighted Graph 1
This is the minimum spanning tree for the graph with a total cost of 51.
Kruskal’s Algorithm: Since some graphs are much more complicated than the previous example, we can use Kruskal’s Algorithm to always be able to find the minimum spanning tree for any graph.
Example 6.2.5: Using Kruskal’s Algorithm
Figure 6.2.7: Weighted Graph 2
Suppose that it is desired to install a new fiber optic cable network between the six cities (A, B, C, D, E, and F) shown above for the least total cost. Also, suppose that the fiber optic cable can only be installed along the roadways shown above. The weighted graph above shows the cost (in millions of dollars) of installing the fiber optic cable along each roadway. We want to find the minimum spanning tree for this graph using Kruskal’s Algorithm.
Step 3: Find the next cheapest link of the whole graph and mark it in red as long as it does not create a red circuit. The next cheapest link is between C and E with a cost of seven million dollars.
Figure 6.2.10: Kruskal’s Algorithm Step 3
Step 4: Find the next cheapest link of the whole graph and mark it in red as long as it does not create a red circuit. The next cheapest link is between B and D with a cost of eight million dollars.
Figure 6.2.11: Kruskal’s Algorithm Step 4
Step 5: Find the next cheapest link of the whole graph and mark it in red as long as it does not create a red circuit. The next cheapest link is between A and B with a cost of nine million dollars, but that would create a red circuit so we cannot use it. Therefore, the next cheapest link after that is between E and F with a cost of 12 million dollars, which we are able to use. We cannot use the link between C and D which also has a cost of 12 million dollars because it would create a red circuit.
Figure 6.2.12: Kruskal’s Algorithm Step 5
This was the last step and we now have the minimum spanning tree for the weighted graph with a total cost of $37,000,000.
Leonhard Euler first discussed and used Euler paths and circuits in 1736. Rather than finding a minimum spanning tree that visits every vertex of a graph, an Euler path or circuit can be used to find a way to visit every edge of a graph once and only once. This would be useful for checking parking meters along the streets of a city, patrolling the streets of a city, or delivering mail.
Euler Path: a path that travels through every edge of a connected graph once and only once and starts and ends at different vertices
Euler Circuit: an Euler path that starts and ends at the same vertex
Example 6.3.2: Euler Circuit
Figure 6.3.3: Euler Circuit Example
One Euler circuit for the above graph is E, A, B, F, E, F, D, C, E as shown below.
Figure 6.3.4: Euler Circuit
This Euler path travels every edge once and only once and starts and ends at the same vertex. Therefore, it is also an Euler circuit.
Euler’s Theorems:
Euler’s Theorem 1: If a graph has any vertices of odd degree, then it cannot have an Euler circuit.
If a graph is connected and every vertex has an even degree, then it has at least one Euler circuit (usually more). Euler’s Theorem 2 : If a graph has more than two vertices of odd degree, then it cannot have an Euler path.
If a graph is connected and has exactly two vertices of odd degree, then it has at least one Euler path (usually more). Any such path must start at one of the odd-degree vertices and end at the other one. Euler’s Theorem 3 : The sum of the degrees of all the vertices of a graph equals twice the number of edges (and therefore must be an even number).
Therefore, the number of vertices of odd degree must be even.
Finding Euler Circuits:
Example 6.3.3: Finding an Euler Circuit
Figure 6.3.5: Graph for Finding an Euler Circuit
Hamilton Circuit : a circuit that must pass through each vertex of a graph once and only once
Hamilton Path : a path that must pass through each vertex of a graph once and only once
Example 6.4.1: Hamilton Path:
Figure 6.4.1: Examples of Hamilton Paths
a. b. c.
Not all graphs have a Hamilton circuit or path. There is no way to tell just by looking at a graph if it has a Hamilton circuit or path like you can with an Euler circuit or path. You must do trial and error to determine this. By the way if a graph has a Hamilton circuit then it has a Hamilton path. Just do not go back to home.
Graph a. has a Hamilton circuit (one example is ACDBEA)
Graph b. has no Hamilton circuits, though it has a Hamilton path (one example is ABCDEJGIFH)
Graph c. has a Hamilton circuit (one example is AGFECDBA)
Complete Graph : A complete graph is a graph with N vertices in which every pair of vertices is joined by exactly one edge. The symbol used to denote a complete graph is KN.
Example 6.4.2: Complete Graphs
Figure 6.4.2: Complete Graphs for N = 2, 3, 4, and 5
a. K 2 b. K 3 c. K 4 d. K 5
two vertices and one edge
three vertices and three edges
four vertices and six edges
five vertices and ten edges
In each complete graph shown above, there is exactly one edge connecting each pair of vertices. There are no loops or multiple edges in complete graphs. Complete graphs do have Hamilton circuits.
Reference Point : the starting point of a Hamilton circuit
Example 6.4.3: Reference Point in a Complete Graph
Many Hamilton circuits in a complete graph are the same circuit with different starting points. For example, in the graph K 3 , shown below in Figure 6.4.3, ABCA is the same circuit as BCAB, just with a different starting point (reference point). We will typically assume that the reference point is A.
Figure 6.4.3: K 3
A
C B
Suppose a delivery person needs to deliver packages to three locations and return to the home office A. Using the graph shown above in Figure 6.4.4, find the shortest route if the weights on the graph represent distance in miles.
Recall the way to find out how many Hamilton circuits this complete graph has. The complete graph above has four vertices, so the number of Hamilton circuits is:
(N – 1)! = (4 – 1)! = 3! = 321 = 6 Hamilton circuits.
However, three of those Hamilton circuits are the same circuit going the opposite direction (the mirror image).
Hamilton Circuit Mirror Image Total Weight (Miles)
ABCDA ADCBA 18 ABDCA ACDBA 20 ACBDA ADBCA 20
The solution is ABCDA (or ADCBA) with total weight of 18 mi. This is the optimal solution.
B. Nearest-Neighbor Algorithm:
Example 6.4.6: Nearest-Neighbor Algorithm
A delivery person needs to deliver packages to four locations and return to the home office A as shown in Figure 6.4.5 below. Find the shortest route if the weights represent distances in miles.
Starting at A, E is the nearest neighbor since it has the least weight, so go to E. From E, B is the nearest neighbor so go to B. From B, C is the nearest neighbor so go to C. From C, the first nearest neighbor is B, but you just came from there. The next nearest neighbor is A, but you do not want to go there yet because that is the starting point. The next nearest neighbor is E, but you already went there. So go to D. From D, go to A since all other vertices have been visited.
Figure 6.4.5: Complete Graph for Nearest-Neighbor Algorithm
The solution is AEBCDA with a total weight of 26 miles. This is not the optimal solution, but it is close and it was a very efficient method.
C. Repetitive Nearest-Neighbor Algorithm:
Example 6.4.7: Repetitive Nearest-Neighbor Algorithm
Suppose a delivery person needs to deliver packages to four locations and return to the home office A. Find the shortest route if the weights on the graph represent distances in kilometers.