Summary of Basic Graph Properties

advertisement
Determining Basic Graph Properties
Connectedness
Cyclicity
Non
directional
graphs
1. Run a depth first (stackbased) or breadth first
(queue-based) traversal
(DFT or BFT)
2. The graph is connected
iff all nodes get visited
1. Run a DFT (or BFT)
2. The graph is cyclic iff some
(unvisited) node is inserted into the
stack or queue at least twice, which
will be detected when it is removed
the second (or subsequent ) time(s)
and turns out to already have been
visited (after it was inserted, but
before this instance was removed)
Directional
Graphs
1. Run a series of DFT’s
(or BFT’s, it doesn’t
matter which) starting
from a different node
each time, re-setting all
nodes to “unvisited”
after each run*
2. The graph is strongly
connected iff every DFT
or BFT visits all nodes,
no matter what node is
the starting point
1. Determine each node’s in-degree
(the number of times it appears in
some other node’s adjacency list)
2. Run a topologic traversal (which
requires starting from some node
of in-degree 0)
3. If the algorithm ever fails to find a
node of in-degree 0 when it needs
one, the graph is cyclic; otherwise
(when the entire graph can be
topologically ordered/traversed),
the graph is acyclic**
* There are more efficient algorithms for determining strong connectedness for
directional graphs; the only reason I mention DFT’s and BFT’s here is that
they seem to me the simplest to understand and it helps illustrate their utility.
** Merely determining that the graph is not strongly connected, is not enough, the
two conditions are by no means equivalent: It’s true that any strongly
connected directional graph is cyclic; but it is certainly not the case that every
cyclic graph is strongly connected; so a graph can fail to be strongly connected
but still contain a cycle.
Finding Articulation Points:
1. Determine that the graph is connected in the first place (strongly connected, for a
directional graph).
2. For each node:
a. Construct a new graph by removing that node from the original graph:
i. Remove the node from the node list
ii. Search all adjacency lists and remove it from all of them as well
b. If the resultant graph is not connected (or, for a directional graph, strongly
connected), the node is an articulation point.
Download