You are on page 1of 44

SPANNI

NG
LESSER A.
TREES
LOC
MTH 610- GRAPH THEORY
NOT TREE TREE

NOT TREE TREE NOT TREE

RECALL: TREES ARE GRAPHS THAT


HAVE NO CIRCUITS
NOT TREE TREE

NOT TREE TREE NOT TREE

RECALL: SUBGRAPH IS A GRAPH WHOSE


VERTICES AND EDGES ARE SUBSETS OF THE
SPANNING TREES
A tree T is a
spanning tree
of a graph G
if T is a
subgraph of G
that contains
all the vertices
of G. G T

MTH 610- GRAPH THEORY


MTH 610- GRAPH THEORY
SPANNING TREES

A spanning tree
is a subset of
graph G which
has all the
vertices covered
with minimum
number of edges. G T

MTH 610- GRAPH THEORY


SPANNING TREES

A spanning tree
does not have
cycles and cannot
be disconnected

G T

MTH 610- GRAPH THEORY


SPANNING TREES
Examples:

MTH 610- GRAPH THEORY


GENERAL PROPERTIES OF
SPANNING TREES

1. A connected graph G can have


more than one spanning tree.
2. All possible spanning trees of graph
G have the same number of edges and
vertices.

MTH 610- GRAPH THEORY


GENERAL PROPERTIES OF
SPANNING TREES

3. The spanning trees does not have


any cycles.
4. Removing one edge from the
spanning tree will make the graph
disconnected, that is, the spanning
tree is minimally connected.

MTH 610- GRAPH THEORY


GENERAL PROPERTIES OF
SPANNING TREES

5. Adding one edge to the spanning


tree will create a circuit or a loop, that
is, spanning tree is maximally acyclic.

MTH 610- GRAPH THEORY


MATHEMATICAL PROPERTIES OF
SPANNING TREES
1. Spanning tree has edges, where n is
the number of nodes or vertices

2. From a complete graph, by


removing edges, we can construct a
spanning tree. 6 − 4+1=3
3. A complete graph can have
maximum of spanning trees.
MTH 610- GRAPH THEORY
SPANNING TREES

Theorem 9.3.4
A graph G has a spanning tree if and
only if G is connected.

MTH 610- GRAPH THEORY


SPANNING TREES
Proof:
Suppose that G contains a cycle. We remove an
edge(but no vertices) from this cycle. The graph
produced is still connected. If it is acyclic, we
stop. If it contains a cycle, we remove an edge
from this cycle. Continuing in this way, we
eventually produce an acyclic, connected
subgraph T. By Theorem 9.2.3, T is a tree. Since T
contains all the vertices of G, T is a spanning tree
of G.

MTH 610- GRAPH THEORY


FINDING SPANNING TREES

1. Breadth-first search

The idea of breadth-first search is to


process all the vertices on a given level
before moving to the higher level.

MTH 610- GRAPH THEORY


FINDING SPANNING TREES
1. Breadth-first search
root
1. Select an ordering of
the vertices. e.g.
abcdefg. ``
2. Select the first vertex
a and label it the
root.

MTH 610- GRAPH THEORY


FINDING SPANNING TREES
1. Breadth-first search
root
3. Add to T all
edges , and
vertices on ``
which that are
incident, for

MTH 610- GRAPH THEORY


FINDING SPANNING TREES
1. Breadth-first search
Vertices on level 1 root

b: (b, d)
c: (c, e) ``
g: none
Vertices on level 2
d: (d, f)
e: none
Vertices on level 3
f: (f, h)
MTH 610- GRAPH THEORY
FINDING SPANNING TREES
1. Breadth-first search
Breadth-first search can also be used to
find the minimum-length paths in an un-
weighted graph from a fixed vertex v to
all other vertices. Dijkstra’s shortest path
algorithm for weighted graphs can be
considered as a generalization of the
breadth-first search.

MTH 610- GRAPH THEORY


FINDING SPANNING TREES
2. Depth-first search
This type of search proceeds to
successive levels in a tree at the
earliest possible opportunity. It
uses the process called
backtracking.

MTH 610- GRAPH THEORY


FINDING SPANNING TREES
2. Depth-first search
root
1. Select an ordering of
the vertices. e.g.
abcdefg. ``
2. Select the first vertex
a and label it the root.
Now we add the edge
, with minimal x to
our tree.

MTH 610- GRAPH THEORY


COUNTING SPANNING TREES

A complete
undirected graph
can have a maximum
of number of
spanning trees,
where n is the
number of nodes.
n− 2 3 −2
n =3 =3
MTH 610- GRAPH THEORY
COUNTING SPANNING TREES

To find the number of spanning trees,


count the number of edges of each
disjoint circuit and multiply those
together. If circuits share edges,
subtract from the result.

MTH 610- GRAPH THEORY


COUNTING SPANNING TREES
𝑒2
𝑒1 𝑒4
3 ∙ 3= 9
𝑒5
𝑒3
𝑒6
G T
v=5 v=5
e=6 e=4 (n-1)

MTH 610- GRAPH THEORY


COUNTING SPANNING TREES
G T
𝑒1 v=6 v=6
𝑒2 e=7 e=5
𝑒3 3 ∙ 3= 9
9 −1=8
𝑒4 𝑒5 𝑒7 8 𝑆𝑝𝑎𝑛𝑛𝑖𝑛𝑔𝑇𝑟𝑒𝑒𝑠
, , ,
, ,
𝑒6 ,
,
, ,

MTH 610- GRAPH THEORY


COUNTING SPANNING TREES

G T 12 spanning
v=13 v=13 trees
e=14 e=12 r=2

MTH 610- GRAPH THEORY


Kirchoff's theorem is
useful in finding the
number of spanning
trees that can be
formed from a
connected graph.
COUNTING SPANNING TREES

STEP 1: Create Adjacency Matrix


for the given graph.

MTH 610- GRAPH THEORY


COUNTING SPANNING TREES
STEP 2: Replace all the
diagonal elements with
the degree of nodes. For
e.g. element at (1,1)
position of adjacency
matrix will be replaced by
the degree of node 1,
element at (2,2) position of
adjacency matrix will be
replaced by the degree of
node 2, and so on.

STEP 3: Replace all non-diagonal 1’s with -1.


MTH 610- GRAPH THEORY
COUNTING SPANNING TREES
STEP 4: Calculate co-
factor for any
element.

STEP 5: The cofactor


that you get is the
total number of
spanning tree for
that graph.

MTH 610- GRAPH THEORY


COUNTING SPANNING TREES

3
2
2
-1
3 8

-1 3 16 − 8= 8
-1 -1

18 -1 -1 16
8 𝑆𝑝𝑎𝑛𝑛𝑖𝑛𝑔𝑇𝑟𝑒𝑒𝑠
MTH 610- GRAPH THEORY
Minimum Spanning Tree (MST)
In a weighted graph, a minimum spanning tree is a
spanning tree that has minimum weight than all other
spanning trees of the same graph. In real-world
situations, this weight can be measured as distance,
congestion, traffic load or any arbitrary value denoted
to the edges.
Two famous Algorithms for finding the Minimum
Spanning Tree
•Kruskal's Algorithm
•Prim's Algorithm
KRUSKAL’S ALGORITHM
Kruskal's algorithm to find the minimum
cost spanning tree uses the greedy
approach. This algorithm treats the graph
as a forest and every node it has as an
individual tree. A tree connects to another
only and only if, it has the least cost
among all available options and does not
violate MST properties.
EXAMPLE:
Step 1 − Remove all loops and Parallel
Edges
EXAMPLE:
Step 1 − Remove all loops and Parallel
Edges
EXAMPLE:Step 2 − Arrange all edges in their
increasing order of weight
EDGES WEIGHT

(B,D) 2

(D,T) 2

(A,C) 3

(C,D) 3

(C,B) 4

(B,T) 5

(A,B) 6

(S,A) 7

(S,C) 8
EXAMPLE:
Step 3 − Add the edge which has
the least weightage
EDGES WEIGHT

(B,D) 2

(D,T) 2

(A,C) 3

(C,D) 3

(C,B) 4

(B,T) 5

(A,B) 6

(S,A) 7

(S,C) 8
PRIM’S ALGORITHM
Prim's algorithm to find minimum
cost spanning tree (as Kruskal's
algorithm) uses the greedy approach.
Prim's algorithm shares a similarity
with the shortest path
first algorithms.
EXAMPLE:
Step 1 − Remove all loops and Parallel
Edges
EXAMPLE:
Step 1 − Remove all loops and Parallel
Edges
EXAMPLE:Step 2 - Choose any arbitrary
node as root node
EXAMPLE:Step 3 - Check outgoing edges
and select the one with less cost
References
Book:
Jonsonbaugh, R. (2009). Discrete Mathematics 7th Ed. New Jersey:
Pearson Education, Inc.

Online References
https://www.geeksforgeeks.org/total-number-spanning-trees-graph/
https://www.tutorialspoint.com/data_structures_algorithms/spannin
g_tree.htm
https://www.youtube.com/watch?v=dr8JOxrnBoY&t=305s
https://www.youtube.com/watch?v=dIKaP0Ozvhs&t=6s
https://www.youtube.com/watch?v=xFv_Hl4B83A

MTH 610- GRAPH THEORY


Thank
you!
MTH 610- GRAPH THEORY

You might also like