Module 8 - Mathematics of Graphs
Module 8 - Mathematics of Graphs
MATHEMATICS OF GRAPHS
A graph – is a set of points called vertices or nodes and line segments or curves called edges that connect vertices.
A graph may also contain a loop. A loop is an edge that begins and ends at the same vertex.
Graphs can be used to represent different scenarios: cities or map, floor plans for houses, border relationships of states or countries
or family relationships between people.
multigraph pseudograph
• Walk – alternating sequences of vertices and edges, with each edge being incident to the vertices immediately preceding
and succeeding it in the sequence.
• Trail – walk with no repeated edges.
• Path – walk with no repeated vertices.
• Closed walk – walk with its initial vertex as also its terminal vertex.
• Open walk – walk with its initial vertex different from its terminal vertex.
• Cycle – closed trail with at least one edge and no repeated vertices except that the initial vertex is the terminal vertex.
• Girth of a graph – length of a shortest (simple) cycle in the graph
• Circumference of a walk – length of the longest cycle in the graph
• Length of a walk – number of edges in the sequence defining the walk; thus the length of a path or cycle is also the
number of edges in the path or cycle
• If u and v are the vertices, the distance from u to v is the length of the shortest path from u to v.
A B
X Z
Y
Answers:
• AZ Walk: (ABZ), (ABYZ), (AXYBZ), (ABYXABYZBZ)
• AZ Trail: (ABZ), (ABYZ), (AXYZ), (AXYBZ)
• AZ Path: (ABZ), (ABYZ), (AXYZ), (AXYBZ)
• G cycles: (ABZYXA), (ABYXA), (BYZB)
• Girth of G: 3
• Circumference of G: 5
Connected Graph – graph in which every pair of its vertices is connected by a path; otherwise, the graph is disconnected
Page 2
Prepared by:
Prof. Ninfa Sua – Sotomil
Cell No: 09171022328
Tel No: 5035955
[email protected]
A graph that is disconnected two or more pieces, called components of the graph.
• cut vertex/cut point – vertex whose removal disconnects the remaining subgraph
• bridge/cut edge – edge whose removal disconnects the graph
A C
E
F
D D
Traversable Graph
A graph is traversable if you can draw a path between all the vertices without retracing the same path. Based on this path, t here
are some categories like Euler’s path and Euler’s circuit which are described in this module.
Euler’s Path
An Euler’s path contains each edge of ‘G’ exactly once and each vertex of ‘G’ at least once. A connected graph G is said to b e
traversable if it contains an Euler’s path.
Example
Euler’s Circuit
In a Euler’s path, if the starting vertex is same as its ending vertex, then it is called an Euler’s circuit.
Example
Page 3
Prepared by:
Prof. Ninfa Sua – Sotomil
Cell No: 09171022328
Tel No: 5035955
[email protected]
Euler’s Path = a-b-c-d-a-g-f-e-c-a.
Euler’s Path − b-e-a-b-d-c-a is not an Euler’s circuit, but it is an Euler’s path. Clearly it
has exactly 2 odd degree vertices. Figure on the right.
Note − In a connected graph G, if the number of vertices with odd degree = 0, then Euler’s
circuit exists.
Hamiltonian Graph
A connected graph G is said to be a Hamiltonian graph, if there exists a cycle which contains all the
vertices of G.
Every cycle is a circuit but a circuit may contain multiple cycles. Such a cycle is called a Hamiltonian
cycle of G.
A path or cycle is Hamiltonian if it uses all vertices exactly once. A graph that contains a Hamiltonian graph is traversable; and one
that contains a Hamiltonian path for any given pair of (distinct) endvertices is a Hamiltonian connected graph.
Hamiltonian Path
A connected graph is said to be Hamiltonian if it contains each vertex of G exactly once. Such a path is called a Hamiltonian path.
Example (Figure on the right)
Hamiltonian Path− e-d-b-a-c.
Note
• Euler’s circuit contains each edge of the graph
exactly once.
• In a Hamiltonian cycle, some edges of the graph
can be skipped.
Example
Take a look at the graph on the right
For the graph shown:
• Euler path exists – false
• Euler circuit exists – false
• Hamiltonian cycle exists – true
• Hamiltonian path exists – true
G has four vertices with odd degree, hence it is not
traversable. By skipping the internal edges, the graph has a
Hamiltonian cycle passing through all the vertices.
Page 4
Prepared by:
Prof. Ninfa Sua – Sotomil
Cell No: 09171022328
Tel No: 5035955
[email protected]
A graph is traversable if there is trail that which includes all vertices and passes each edge exactly once. In other words, “it can
be drawn without any break in the curve and without repeating any edges.”
Example:
A graph with more than 2 vertices with an odd degree is not traversable.
Eulerian Graph
A trail or circuit (or cycle) is Eulerian if it uses all edges precisely once. A graph that contains an Eulerian trail is
traversable. A graph that contains an Eulerian circuit is an Eulerian graph.
Parallel edges - In a digraph, a pair of edges in which one is directed from vertex a to vertex b and the other is directed from
vertex b to vertex a.
A E
B C D
Page 5
Prepared by:
Prof. Ninfa Sua – Sotomil
Cell No: 09171022328
Tel No: 5035955
[email protected]
In a digraph, we distinguish the out-degree as the number of edges leaving a vertex, and the in-degree, the number of edges
entering a vertex. The degree of a vertex, is the sum of its out-degree and in-degree.
Example:
a b
c d
f e
Source: a
Sink: c and d
a b c d e f g
In-degree 0 2 2 4 1 2 1
Out-degree 4 1 0 0 3 2 2
Degree 4 3 2 4 4 4 3
Weighted Graph
Weighted graph – associates a value (weight) with every edge in the graph. The weight of a path in a weighted graph is the
sum of the weights of the traversed edges. Sometimes the words cost or length is used instead of weight.
Example:
b 3 d
1 2
2 2 2
a d 4 g h
2 4
2 3
f 3 e
Trees
Tree T – is a simple graph that if u and v are vertices in T, there exists a unique simple walk from u to v. A tree is connected and
an acyclic graph (a graph with no cycle).
Page 6
Prepared by:
Prof. Ninfa Sua – Sotomil
Cell No: 09171022328
Tel No: 5035955
[email protected]
A
A is the root of the tree T.
Height of Tree T is 5.
B C D Level of A is 0. Level of E and F is 2, and level G and H is 3.
The parent of H and I is F.
The ancestors of I are F, D and A.
E F
The children of F are H and I.
The descendants of F are H, I, K and L.
I
G H The vertices H and I are siblings.
The vertices of J, C, K and L are leaves.
K L The vertices B, D, E, F, G, H and I are branches.
J
Tree T
Let G be a graph with more than one vertex, then the following statements are equivalent.
• G is a tree.
o Each pair of vertices is connected to exactly one simple path.
o G is connected but if any edge is deleted, the graph becomes disconnected.
o G is acyclic but if any edge is added, the resulting graph has exactly one cycle.
Spanning Trees
A spanning tree is a sub-graph of an undirected connected graph, which includes all the vertices of the graph with a
minimum possible number of edges. If a vertex is missed, then it is not a spanning tree. The edges may or may not have weights
assigned to them. A tree T is a spanning tree of a Graph G if T is a subgraph of G that contains all the vertices of graph G and T
has no cycle.
Example:
Leonhard Euler of Switzerland analysed the problem and said “No,” it is not possible to walk across all the bridges
without repeating at least one bridge. This is because if we take the land dry places where the bridges connect as nodes or vertices
and the bridges as edges, then we have a vertex with an odd degree.
Page 7
Prepared by:
Prof. Ninfa Sua – Sotomil
Cell No: 09171022328
Tel No: 5035955
[email protected]
Page 8
Prepared by:
Prof. Ninfa Sua – Sotomil
Cell No: 09171022328
Tel No: 5035955
[email protected]