Graph Theory Notes
Graph Theory Notes
● Graphs
● Trees
● Tree design
● Drawback of MST’s
Figure 4.2
The key to Euler's solution was in a very simple abstraction of the
puzzle.Let us redraw our diagram of the city of KÄonigsberg by
representing each of the land masses as a vertex and representing each
bridge as an edge connecting the vertices corresponding to the land
masses. We now have a graph that encodes the necessary information.
The problem reduces to finding a "closed walk" in the graph which
traverses each edge exactly once, this is called an Eulerian circuit.
Graph theory may be said to have its beginning in 1736 when
LEONHARD
EULER considered the (general case of the) k¨onigsberg bridge
problem: Does
there exist a walk crossing each of the seven bridges of K¨onigsberg
exactly once? It took 200 years before the first book on graph theory
was written. This was (Theorie der endlichen und unendlichen
Graphen) (Teubner, Leipzig, 1936) by KONIG in 1936. Since then
graph theory has developed into an extensive and popular branch of
mathematics, which has been applied to many problems in
mathematics, computer science, and other scientific and not-so-
scientific areas.There are no standard notations for graph theoretical
objects. This is natural, because the names one uses for the objects
reflect the applications. Thus, for instance, if we consider a
communications network (say, for email) as a graph, then the
computers taking part in this network, are called nodes rather than
vertices or points. On the other hand, other names are used for
molecular structures in chemistry, flow charts in programming,
human relations in social sciences, and so on.
Definitions
A graph G is defined as: It is a non-empty set of elements called
Vertices with a family of non-ordered pair of the vertices called edges
E. The set of the vertices G denoted by V (G), the family of edges
denoted by E(G) and the graph is denoted by (V, E).
Graphically, we represent a graph by drawing a point for each vertex
and representing each edge by a curve joining its endpoints. For our
purposes all graphs will be finite graphs, i.e. graphs for which V (G)
and E(G) are finite sets, unless specifically stated otherwise.
Note that in our definition, we do not exclude the possibility that the
two endpoints of an edge are the same vertex. This is called a loop,
for obvious reasons. Also, we may have multiple edges, which is
when more than one edge shares the same set of endpoints, i.e. the
edges of the graph are not uniquely determined by their endpoints.
A simple graph is a graph having no loops or multiple edges. In this
case, each edge e in E(G) can be specified by its endpoints u; v in V
(G). Sometimes we write e = uv.
Vertex: A vertex is a dot in the graph where edges meet. A vertex
could represent an intersection of streets, a land mass, or a general
location, like “work” or “school”. Note that vertices only occur when
a dot is explicitly placed, not whenever two edges cross. Imagine a
freeway overpass – the freeway and side street cross, but it is not
possible to change from the side street to the freeway at that point, so
there is no intersection and no vertex would be placed.
Edges: Edges connect pairs of vertices. An edge can represent a
physical connection between locations, like a street, or simply that a
route connecting the two locations exists, like an airline flight.
Loop: A loop is a special type of edge that connects a vertex to itself.
Loops are not used much in street network graphs.
Figure 4.3
Degree of a vertex: The degree of a vertex is the number of edges
meeting at that vertex. It is possible for a vertex to have a degree of
zero or larger.
Figure 4.4
Figure 4.5
Circuit: A circuit is a path that begins and ends at the same vertex. A
circuit starting and ending at vertex A is shown below.
Figure 4.6
Connected: A graph is connected if there is a path from any vertex to
any other vertex.
Weights: Depending upon the problem being solved, sometimes
weights are assigned to the edges. The weights could represent the
distance between two locations, the travel time, or the travel cost. It
is important to note that the distance between vertices in a graph does
not necessarily correspond to the weight of an edge.
Isolated vertex: Is a vertex which has no any edges.
Multiple edge: There is a multiple edge between two vertices u, v if
there is more
than one edge join u, v.
Multigraph:Is a graph with multiedge.
P-graph: G is p-graph if number of repeated each non-ordered pair of
two vertices
is not greater then p.
Figure 4.7
Figure 4.10
4.2.1 Example:
4.2.3 Algorithm
1) Create a set MST Set that keeps track of vertices already included
in MST.
2) Assign a key value to all vertices in the input graph. Initialize all
key values as INFINITE. Assign key value as 0 for the first vertex so
that it is picked first.
3) While MST Set doesn’t include all vertices
a) Pick a vertex u which is not there in MST set and has minimum key
value.
b) Include u to MST Set.
c) Update key value of all adjacent vertices of u. To update the key
values, iterate
through all adjacent vertices. For every adjacent vertex v, if weight of
edge u-v
is less than the previous key value of v, update the key value as
weight of u-v.
The idea of using key values is to pick the minimum weight edge
from cut. The key values are used only for vertices which are not yet
included in MST, the key value for these vertices indicate the
minimum weight edges connecting them to the set of vertices
included in MST.
Let us understand with the following example:
Figure 4.12
The set MST SET is initially empty and keys assigned to vertices are
{0, INF, INF, INF, INF, INF, INF, INF} where INF indicates infinite.
Now pick the vertex with minimum key value. The vertex 0 is picked,
include it in MST SET. So MST SET becomes {0}. After including to
MST SET, update key values of adjacent vertices. Adjacent vertices
of 0 are 1 and 7. The key values of 1 and 7 are updated as 4 and 8.
Following subgraph shows vertices and their key values, only the
vertices with finite key values are shown. The vertices included in
MST are shown in green color
Figure 4.13
Pick the vertex with minimum key value and not already included in
MST (not in MST SET). The vertex 1 is picked and added to MST
SET. So MST SET now becomes {0, 1}. Update the key values of
adjacent vertices of 1. The key value of vertex 2 becomes 8.
Figure 4.14
Pick the vertex with minimum key value and not already included in
MST (not in MST SET). We can either pick vertex 7 or vertex 2, let
vertex 7 is picked. So MST SET now becomes {0, 1, 7}. Update the
key values of adjacent vertices of 7. The key value of vertex 6 and 8
becomes finite (7 and 1 respectively).
Figure 4.15
Pick the vertex with minimum key value and not already included in
MST (not in MST SET). Vertex 6 is picked. So MST SET now
becomes {0, 1, 7, 6}. Update the key values of adjacent vertices of 6.
The key value of vertex 5 and 8 are updated.
Figure 4.16
We repeat the above steps until MST SET doesn’t include all vertices
of given graph. Finally, we get the following graph.
Figure 4.17
is a separate tree
● create a set S containing all the edges in the graph
● if that edge connects two different trees, then add it to the forest,
Figure 4.18
After sorting:
Weight Src Dest
1 7 6
2 8 2
2 6 5
4 0 1
4 2 5
6 8 6
7 2 3
7 7 8
8 0 7
8 1 2
9 3 4
10 5 4
11 1 7
14 3 5
Now pick all edges one by one from sorted list of edges
1. Pick edge 7-6: No cycle is formed, include it.
Figure 4.19
Figure 4.21
Figure 4.22
6. Pick edge 8-6: Since including this edge results in cycle, discard it.
7. Pick edge 2-3: No cycle is formed, include it.
Figure 4.24
8. Pick edge 7-8: Since including this edge results in cycle, discard it.
Figure 4.25
10. Pick edge 1-2: Since including this edge results in cycle, discard
it.