0% found this document useful (0 votes)
19 views16 pages

Spanning Trees

Breadth-first search (BFS) and depth-first search (DFS) can both be used to find the connected components and spanning trees of graphs. BFS finds a spanning tree in Θ(n+e) time by using forward edges between visited and unvisited vertices. DFS also finds spanning trees and can obtain the reflexive transitive closure matrix in Θ(n^2) time and Θ(n) space. Minimum-cost spanning trees minimize the total cost or weight of edges in the tree.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views16 pages

Spanning Trees

Breadth-first search (BFS) and depth-first search (DFS) can both be used to find the connected components and spanning trees of graphs. BFS finds a spanning tree in Θ(n+e) time by using forward edges between visited and unvisited vertices. DFS also finds spanning trees and can obtain the reflexive transitive closure matrix in Θ(n^2) time and Θ(n) space. Minimum-cost spanning trees minimize the total cost or weight of edges in the tree.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

CONNECTED COMPONENTS AND

SPANNING TREES
 If G is a connected undirected graph, then all
vertices of G will get visited on the first call to
BFS.

 If G is not connected then 2 calls are needed.


 Hence BFS can be used to determine whether G
is connected. The connected component can also
be got using BFT.
 If adjacency lists are used, a breadth first
traversal will obtain the connected components in
Θ(n+e) time.
 Another application of BFS is obtaining a
spanning tree for an undirected graph G.
 G has a spanning tree if G is connected. BFS
easily determines the existence of spanning trees.
Consider the set of edges (u,w) is used to reach
unvisited vertices w. These edges are called
forward edges.
 Let t denote the set of these forward edges.
 If G is connected, then t is a spanning tree of G.
 Spanning Trees
 Let G be a connected graph. A spanning tree in G
is a subgraph of G that includes all the vertices of
G and is also a tree. The edges of the trees are
called branches.
 Theorem:A graph is connected if and only if it has a
spanning tree.

 Proof Let G be a connected graph. Delete edges from


G that are not bridges until we get a connected subgraph
H in which each edge is a bridge. Then H is a spanning
tree. On the other hand, if there is a spanning tree in G,
there is a path between any pair of vertices in G; thus G
is connected.

 A tree T is a spanning tree of a connected graph
G(V<E) such that
1) Every vertex of G belongs to an edge in T &

2) The edges in T form a tree.


Take any vertex v as an initial partial tree and add
edges one by one so that each edge joins a new
vertex to the partial tree. If there are n vertices in
the graph we shall construct a spanning tree in
(n-1) steps.i.e . (n-1) edges are needed to be
added.
SPANNING TREES
 Spanning tree of a graph is a connected subgraph
in which there are no cycles.

A connected, Four of the spanning trees of the graph


undirected graph
FINDING A SPANNING TREE
 To find a spanning tree of a graph,
pick an initial node and call it part of the
spanning tree
do a search from the initial node:
each time you find a node that is not in
the spanning tree, add to the spanning
tree both the new node and the edge
you followed to get to it
MINIMIZING COSTS
 Suppose you want to supply a set of houses (say,
in a new subdivision) with:
 electric power
 water
 sewage lines
 telephone lines
 To keep costs down, you could connect these
houses with a spanning tree (of, for example,
power lines)
 However, the houses are not all equal distances apart
 To reduce costs even further, you could connect
the houses with a minimum-cost spanning tree
10
 The connected components of a graph can be
obtained using DFT. Similarly the reflexive
transitive closure matrix of an undirected graph
can be found using DFT. A spanning tree can be
obtained using DFT is called depth first spanning
tree.

 Hence DFS and BFS are equally powerful .


MINIMUM-COST SPANNING TREES
 Suppose you have a connected undirected graph with a weight (or
cost) associated with each edge
 The cost of a spanning tree would be the sum of the costs of its edges
 A minimum-cost spanning tree is a spanning tree that has the lowest
cost
 Suppose you have a connected undirected graph with a weight (or
cost) associated with each edge
 The cost of a spanning tree would be the sum of the costs of its edges
 A minimum-cost spanning tree is a spanning tree that has the lowest
cost
 BFT can also be used to obtain the reflexive
transitive closure matrix of an undirected graph
G. If A* is this matrix, then A* (i,j) =1 if either i=j
or i≠j and I and j are in the same connected
component.

 The reflexive transitive closure of an undirected


graph G with n vertices and e edges can therefore
be computed in ө(n2) time and ө(n) space using
either adjacency lists or matrices
BICONNECTED COMPONENTS AND DFS
 A vertex v in a connected graph G is an
articulation point if and only if the deletion of
vertex v together with all edges incident to v
disconnects the graph into two or more non
empty components.
 A graph G is biconnected if and only if it contains
no articulation points.

You might also like