0% found this document useful (0 votes)
314 views

Singly Connected Graph

The document describes an algorithm to determine if a directed graph is singly connected. It first computes the strongly connected components of the graph. It then checks if there are multiple edges between any two vertices in the strong component graph, which would mean the graph is not singly connected. Alternatively, it performs DFS on each vertex, checking for forward or cross edges within components. If no such edges exist, the graph is singly connected. The time complexity is O(|V|(|V|+|E|)).

Uploaded by

Jay Shrotriya
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
314 views

Singly Connected Graph

The document describes an algorithm to determine if a directed graph is singly connected. It first computes the strongly connected components of the graph. It then checks if there are multiple edges between any two vertices in the strong component graph, which would mean the graph is not singly connected. Alternatively, it performs DFS on each vertex, checking for forward or cross edges within components. If no such edges exist, the graph is singly connected. The time complexity is O(|V|(|V|+|E|)).

Uploaded by

Jay Shrotriya
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ALGORITHMS

A directed graph G =(V , E)is singly


connected if u --> v implies that G contains
at most one simple path from u to v for all
vertices (u,v) belongs to V .
Give an efficient algorithm to determine
whether or not a directed graph is singly
connected.
ALGORITHM:-
We first compute the strongly connected
components of the graph.
Once we compute the strong component graph
we check to see if there are any multiple edges in
this graph between two vertices.
If there are multiple edges between two vertices
then this implies that there are two strongly
connected components with multiple edges
between them, it is easy to see that in this case
the graph cannot be singly connected.
If a strongly connected graph has either a cross edge or a
forward edge or double back edges then it is not singly
connected.
STEPS:-

For each vertex u in V , perform a DFS on the given
graph G.
DFS will process the vertices first deep and then wide.
After processing a vertex it recursively processes all
of its descendants.
Check if there are any forward edges or cross edges (in
the same component) in any one of the searches.
If no such edges exist, then the graph is singly
connected, else not.
Time complexity: O(|V |(|V | + |E|)).
The graph is singly connected even with back edges
existed. Since back edges implies there is a path u to v
and v to u, which is consistent with the definition of
single connectedness.
DFS{G} {
for each u in V do // Initialize
color[u] = white;
pred[u] = NULL;
time=0;
for each u in V do
// start a new tree
if (color[u] == white) DFSVisit(u);}

DFSVisit(u) {
color[u] = gray; // u is discovered
d[u] = ++time; // u discovery time
for each v in Adj(u) do
// Visit undiscovered vertex
if (color[v] == white) {
pred[v] = u;
DFSVisit(v);}

color[u] = black; // u has finished
f[u] = ++time; // u finish time}

You might also like