AppendIx C
■
GrAph TermInoloGy
271
Note
■
As opposed to subgraphs in general, the term
subtree usually does
not apply to all subgraphs that happen
to be trees—especially not if we are talking about rooted trees.
Other similar terms generally have their obvious meanings. For example,
siblings are nodes with a common
parent. Sometimes siblings are
ordered so that we can talk about the “first child” or “next sibling”
of a node, for
example. In this case, the tree is called an
ordered tree.
As explained in Chapter 5, many algorithms are based on
traversal, exploring graphs systematically, from some
initial starting point (a start node). Although the way graphs are explored may differ, they have something in common.
As long as they traverse the entire graph, they all give rise to
spanning trees.
6
(Spanning trees are simply spanning
subgraphs that happen to be trees.) The spanning tree resulting from a traversal, called the
traversal tree,
is rooted at
the starting node. The details of how this works will be revisited when dealing with the individual algorithms, but graph
G
4
in Figure
C-1
illustrates the concept. The highlighted subgraph is such a traversal tree, rooted at
a. Note that all paths
from
a to the other nodes in the tree follow the edge directions; this is always the case for traversal trees in digraphs.
Note
■
A digraph whose underlying graph is a rooted tree and where all the directed edges point away from the root
(that is, all nodes can be reached by directed paths from the root) is called an
arborescence, even though I’ll mostly talk
about such graphs simply as trees. In other words, traversal in a digraph really gives you a
traversal arborescence.
The term
oriented tree is used about both rooted (undirected) trees and arborescences because
the edges of a rooted
tree have an implicit direction away from the root.
Terminology fatigue setting in yet? Cheer up—only one graph concept left. As mentioned, directed graphs can
be acyclic, just as undirected graphs can. The interesting thing is that these graphs don’t generally look much like
forests of directed trees. Because the underlying undirected graph can be as cyclic as it wants, a
directed acyclic graph,
or DAG, can have an arbitrary structure (see Exercise 2-11), as long as the edges point in the right directions—that is,
they are pointing so that no
directed cycles exist. An example of this can be seen in sample graph
G
4
.
DAGs are quite natural as representations for dependencies because cyclic dependencies are generally
impossible (or, at least, undesirable). For example, the nodes might be college courses, and an edge (u,v) would
indicate that course u was a prerequisite for v. Sorting out such dependencies is the topic of
the section on topological
sorting in Chapter 5. DAGs also form the basis for the technique of dynamic programming, discussed in Chapter 8.
6
This
is true only if all nodes can be reached from the start node. Otherwise, the traversal may have to restart in several places,
resulting in a
spanning forest. Each component of the spanning forest will then have its own root.