Trees
Trees
Trees
An acyclic graph (also known as a forest) is a graph with no cycles. A tree is a connected acyclic graph. Thus each component of a forest is tree, and any tree is a connected forest.
Theorem vertices.
i. ii. iii. iv. v. vi. vii.
G is a tree. There is a unique path between every pair of vertices in G. G is connected, and every edge in G is a bridge. G is connected, and it has (n - 1) edges. G is acyclic, and it has (n - 1) edges. G is acyclic, and whenever any two arbitrary nonadjacent vertices in G are joined by and edge, the resulting enlarged graph G' has a unique cycle. G is connected, and whenever any two arbitrary nonadjacent vertices in G are joined by an edge, the resulting enlarged graph has a unique cycle.
Generally speaking, algorithms associated with trees can be divided into three types.
Algorithms for searching and labeling a given tree. Algorithms for constructing various types of tree. Algorithms for counting trees of a particular type.
Tree
For example,
Theorem Let T be a graph with n vertices. Then the following statements are equivalent.
a. T is connected and contains no cycles. b. T is connected and has n-1 edges. c. T has n-1 edges and contains no cycles. d. T is connected and each edge is abridge.
e. Any two vertices of T are connected by exactly one path. f. T contains no cycles, but the addition of any new edge creates exactly one cycles.
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. For example, consider the following graph G
Remove one of cycle's edges. Repeat this procedure until there are no cycle left.
1. We remove the edge ac which destroy the cycle adca in the above graph and we get
2. We remove the edge cb, which destroy the cycle adcba in the above graph and we get
3. We remove the edge ec, which destroy the cycle decd in the above graph and thus obtained the following spanning tree.
Building-up Method o Select edges of G one at a time. in such a way that no cycles are created.
o
4. Finally, we choose the edge cb and thus obtain the following spanning tree.
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.
Algorithm1
Remove all the vertices of degree1, together with their incident edges. Repeat the process until we obtain either a single vertex (the center) or two vertices joined by an edge (the bicenter).
A tree with a center is called a central tree, and a tree with a bicenter is called a bicentral tree. Note that every tree is either central or bicentral, but not both.
Algorithm 2
For each vertex v of the degree 2 or more, count the number of vertices in each of the subtrees emanating from v, and let nv be the maximum of these numbers. If the tree has n vertices it can be shown that either there is just one vertex v for which nv 1/2(n-1) (the centroid or centroid tree) or there are two adjacent vertices v and w for which nv = nw = 1/2n (the bicentroid or bicentroid tree). It is easy to see that every tree is either centroidal or bicentroidal, but not both. Note that we can think of the centroid or bicentroid as the 'center of gravity' of the tree. For example, given a following tree
Tree Searching
There are two well-known search methods. They are brown as depth-first search( DFS) and breadth-first search (BFS). Each of these methods lists the vertices as they are encountered, and indicates the direction in which each edge is first traversed. The methods differ only in the way in which the vertex-lists are constructed.
a -> b --> d --> i -> j -> k -> e -> c -> f -> i -> g -> h.
Note that we have marked those edges we used when going to new vertex. These edges form a spanning tree, called a DFS spanning tree.
a --> b --> c --> d --> e --> f --> g --> h --> i --> j --> k --> e above example clearly shows that breadth-first search must complete each level before proceeding to the next one. Example: Consider the graph
Note that we have marked those edges we used when going to new vertex. These edges form a spanning tree, called a BFS spanning tree.