Graphs and Graph Traversals

advertisement
Graphs and Graph Traversals
Section 7.1
Graphs can solve several problems in linear time -- easy
problems. Graphs of million nodes can be solved.
Other problems require revisiting nodes of the graph – medium
problems. Polynomial time problems such as n2, n3. Graphs
with thousands or tens of thousands can be solved.
Still other problems are hard, requiring revisiting nodes of the
graph several times. 2n. Graphs with 50 to 100 nodes can be
solved.
Section 7.2 Definitions and Representations
Graph is a 2 tuple G = (V,E)
set of Vertices or nodes - V
set of Edges: E  V x V
undirected are two way
directed are one way
Examples: airline routes, flowcharts, binary relation, computer
networks, electrical circuits
subgraph some of a graph – given G=(V,E), G’=(V’,E’) where
V’V, E’E. G’ is a subgraph of G.
symmetric digraph - if there exists an edge uv there must be
an edge vu.
adjacency relation - two vertices connected by an edge.
path – sequence of edges
cycle – sequence of edges where initial node is the final node
weighted graph – can include weights in the adjacency matrix
or in the nodes of an adjacency list.
adjacency representation
adjacency list
depth first traversal
breadth first traversal
topological order
Section 7.7
Biconnected Components of an Undirected Graph
If any one vertix (and the edges incident upon it) are removed
from a
connected graph, is the remaining subgraph still connected?
Biconnected component
A connected undirected graph G is said to be biconnected if
it
remains connected after removal of any one vertex and the
edges
that are indicent upon that vertex.
Articulation point
A vertex v is an articulation point (also called cut point) for
an
undirected graph G if there are distinct vertices w and x
(distinct
from v also) such that v is in every path from w to x.
Clearly, biconnected iff no articulation points.
Algorithm does a depth first search.
Section 7.7.2 The Biomponent Algorithm
Bicomponent algorithm tests to see if a vertex in the depth
first
search tree is an articulation point each time the search
backtracks
to it.
Suppose the search is backing up to v from w. If there is no
back
edge from any vertex in the subtree rooted at w to a proper
ancestor
of v, then v must be on every path in G from the root of the
DFS
tree to w and is therefore an articulation point.
The algorithm must keep track of how far back in the tree one
can
get from each vertex by following tree edges (implicity
directed
away from the root) and certain back edges.
In a depth first search tree, a vertex v, other than the root, is
an
articulation point if and only if v is not a leaf and some
subtree
of v has no back edge incident with a proper ancestor of v.
Download