1 / 10

Graphs and Trees

Graphs and Trees. This handout: Trees Minimum Spanning Tree Problem www.ohio.edu/people/melkonia/math3050/.../ trees . ppt. Terminology of Graphs: Cycles, Connectivity and Trees. A path that begins and ends at the same node is called a cycle . Example:

mbissonette
Download Presentation

Graphs and Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphs and Trees • This handout: • Trees • Minimum Spanning Tree Problem • www.ohio.edu/people/melkonia/math3050/.../trees.ppt

  2. Terminology of Graphs: Cycles, Connectivity and Trees • A path that begins and ends at the same node is called a cycle. Example: • Two nodes are connected if there is a path between them. • A graph is connected if every pair of its nodes is connected. • A graph is acyclic if it doesn’t have any cycle. • A graph is called a tree if it is connected and acyclic. Example:

  3. Examples/Applications of Trees • Family tree • Evolutionary tree • Possibility tree • Prime number factorization tree • Spanning tree of a telecom network (considered later in this handout) • Hydrocarbon molecules

  4. Properties of Trees • Definition: Let T be a tree. If T has at least 3 nodes, then • A node of degree 1 in T is called a leaf (or a terminal node). • A node of degree greater than 1 is called an internal node. • Lemma: Every tree with more than one node has at least one leaf. • Theorem: For any positive integer n, any tree with n nodes has n-1 edges. Proof by induction (blackboard).

  5. Properties of Trees • Lemma: If G is any connected graph, C is a cycle in G, and one of the edges of C is removed from G, then the graph that remains is still connected. • Theorem: For any positive integer n, if G is a connected graph with n vertices and n-1 edges, then G is a tree. • Theorem: For any positive integer n, if G is an acyclic graph with n vertices and n-1 edges, then G is a tree. Proofs on blackboard.

  6. Rooted Trees r • Definition: A rooted tree is a tree in which one vertex is distinguished from the others and is called the root. • The level of a vertex is the number of edges along the unique path between it and the root. • The height of a rooted tree is the maximum level to any vertex of the tree. • The children of a vertex v are those vertices that are adjacent to v and one level farther away from the root than v. • When every vertex in a rooted tree has at most two children, the tree is called a binary tree. a b c d

  7. 3 3 b b d d 2 2 8 8 a a 3 3 5 5 7 7 4 4 e e c c 4 4 Minimum Spanning Tree Problem • Given: Graph G=(V, E), |V|=n Cost function c: E  R . • Goal: Find a minimum-cost spanning tree for V i.e., find a subset of arcs E*  E which connects any two nodes of V with minimum possible cost. • Example: Min. span. tree: G*=(V,E*) G=(V,E) Red bold arcs are in E*

  8. Algorithm for solving the Minimum Spanning Tree Problem • Initialization: Select any node arbitrarily, connect to its nearest node. • Repeat • Identify the unconnected node which is closest to a connected node • Connect these two nodes Until all nodes are connected Note: Ties for the closest node are broken arbitrarily.

  9. 3 3 b b d d 2 2 8 8 a a 3 3 5 5 7 7 4 4 e e c c 4 4 The algorithm applied to our example • Initialization: Select node a to start. Its closest node is nodeb. Connect nodesa and b. • Iteration 1: There are two unconnected node closest to a connected node: nodes c and d (both are 3 units far from node b). Break the tie arbitrarily by connecting node c to node b. Red bold arcs are in E*; thin arcs representpotential links.

  10. 3 3 b b d d 2 2 8 8 a a 3 3 5 5 7 7 4 4 e e c c 4 4 The algorithm applied to our example • Iteration 2: The unconnected node closest to a connected node is noded (3far from node b). Connect nodes b and d. • Iteration 3:The only unconnected node left is node e. Its closest connected node is node c (distance between c and e is 4). Connect node e to node c. • All nodes are connected. The bold arcs give a min. spanning tree.

More Related