1 / 84

Algorithms for Enumerating All Spanning Trees of Undirected and Weighted Graphs

Algorithms for Enumerating All Spanning Trees of Undirected and Weighted Graphs. Sanjiv Kapoor and H.Ramesh. Presented by R97922102 李孟哲 R97922104 陳翰霖 R97922124 張仕明. Index. Introduction Computation Tree Algorithm 1 Algorithm 2 Algorithm 3. Introduction.

dylan-brown
Download Presentation

Algorithms for Enumerating All Spanning Trees of Undirected and Weighted Graphs

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. Algorithms for Enumerating All Spanning Trees of Undirected and Weighted Graphs Sanjiv Kapoor and H.Ramesh Presented by R97922102 李孟哲 R97922104 陳翰霖 R97922124 張仕明

  2. Index • Introduction • Computation Tree • Algorithm 1 • Algorithm 2 • Algorithm 3

  3. Introduction • Spanning tree enumeration in undirected graphs is an important issue in network and circuit analysis • In this paper, author enumerate spanning trees by the computation tree • Every node in the computation tree represent a spanning tree

  4. Algorithms Introduction • We use this way to enumerate all the spanning tree on undirected and weighted graphs. • Algorithm 1 • O(N+V+E) time • O(V2E) space • Algorithm 2 • O(N+V+E) time • O(VE) space • Algorithm 3 (with sorting) • O(NlogV+VE) time • O(N+VE) space

  5. Spanning Tree • The original graph G

  6. Spanning Tree • A Spanning tree of G

  7. Spanning Tree • add a edge to the tree

  8. Spanning Tree • get a cycle (fundamental cycle)

  9. Spanning Tree • remove a edge on the cycle

  10. Spanning Tree • get a new spanning tree of G

  11. Spanning Tree • From this cycle, we can obtain several spanning trees.

  12. Computation Tree

  13. Computation tree • First, we start off with a spanning tree T, and generate all other spanning trees form T by replacing edges in T by edges outside T • For every node x, Sx is the spanning tree corresponding to this node • To ensure that each spanning tree is generated exactly once, we use 2 edge set INx and OUTx for every node x

  14. IN and OUT • The setINxconsist of edges which are always included in node x and it’s descendants • The set OUTx consist of edges which are always not included in node x and it’s descendants • The IN and OUT set of the root are both empty

  15. 1 1 3 3 2 2 4 4 5 5 In =[ ] Out=[ ] S =[ ] , , 1,2,4 Computation tree Arbitrary choose a spanning tree

  16. 1 1 3 3 2 2 4 4 5 5 In =[ ] Out=[ ] S =[ ] , , 1,2,4 Computation tree

  17. 1 1 3 3 2 2 4 4 5 5 In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] , , , , , , , , , , , , , , 1,2,4 Computation tree

  18. 1 1 1 1 3 3 3 3 2 2 2 2 4 4 4 4 5 5 5 5 In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] , , , , , , , , , , 1 1,2,4 2,4,5 1,2,4 1,2,5 1,4,5 3 4 2 5 Computation tree (-2,+5) (-1,+5) (-4,+5) 1 3 2 4 5

  19. 1 1 1 1 3 3 3 3 2 2 2 2 4 4 4 4 5 5 5 5 In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] , , , , , 5, 2, , 4, 1, 1 1,2,4 2,4,5 1,2,4 1,2,5 1,4,5 3 4 2 5 Computation tree (-2,+5) (-1,+5) (-4,+5) 1 3 2 4 5

  20. 1 1 1 1 3 3 3 3 2 2 2 2 4 4 4 4 5 5 5 5 In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] , 5, , 5, 5, 5, 2, , 4, 1, 1 1,2,4 2,4,5 1,2,4 1,2,5 1,4,5 3 4 2 5 Computation tree (-2,+5) (-1,+5) (-4,+5) 1 3 2 4 5

  21. 1 1 1 1 3 3 3 3 2 2 2 2 4 4 4 4 5 5 5 5 In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] , 5, , 5,2,1, 5,2, 5, 2, , 4, 1, 1 1,2,4 2,4,5 1,2,4 1,2,5 1,4,5 3 4 2 5 Computation tree (-2,+5) (-1,+5) (-4,+5) 1 3 2 4 5

  22. 1 1 3 3 2 2 4 4 5 5 In =[ ] Out=[ ] S =[ ] , 5, 1,2,4 Computation tree

  23. 1 1 1 1 3 3 3 3 2 2 2 2 4 4 4 4 5 5 5 5 In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] , , , , 5, 5, 5, 5,3 1,2,4 1,3,4 1,2,4 2,3,4 1 3 4 2 5 Computation tree (-1,+3) (-2,+3)

  24. 1 1 1 1 3 3 3 3 2 2 2 2 4 4 4 4 5 5 5 5 In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] In =[ ] Out=[ ] S =[ ] , 1,3, , 3, 5,1 5,2 5, 5,3 1,2,4 1,3,4 1,2,4 2,3,4 1 3 4 2 5 Computation tree (-1,+3) (-2,+3)

  25. 1 3 2 4 5 Computation tree

  26. Computation tree C’(G)

  27. Appear not only once • The last son and its parent are the same

  28. 1 3 2 4 5 Another Computation tree C’(G) G C’(G) C(G)

  29. Another Computation tree C’(G)

  30. Computation tree C(G)’s property • The son has zero or one edge differ from its parent. • The number of sons equals to the length of the fundamental cycle

  31. Computation tree C’(G)’s property • The son has one edge differ from its parent. • The number of sons equals to the sum of the length of all fundamental cycles

  32. Lemma 1 • The computation tree has at its internal nodes and leaves all the spanning trees of G • [Proof] • Following from induction and inclusion/exclusion principle • Let A be a node of computation tree C(G), B1,...,Bk+1 be the son of A

  33. e1 A e2 f … • All spanning trees in B1,…, Bk contain edge f • All spanning trees in Bk+1 don’t contain edge f • The spanning trees as Bj ‘s descendants contain edges e1,…,ej-1, but the edge ej • e1,…,ek and f form a cycle B1 B2 Bk Bk+1 ek … … … … computation tree

  34. Algorithm 1

  35. The Algorithm 1 Generate a random spanning tree and initialize some data structures. … Prepare and modify the data structures. Recursively call the algorithm.

  36. Possible problem in algorithm • How to maintain the IN , OUT, S ? • How to find the fundamental cycles?

  37. Possible problem in algorithm • How to maintain the IN , OUT, S ? • S is easy, just add a edge and delete another one. • We use a data structure AG to maintain IN, OUT. • We would choose edges from AG • Initial: AG is the graph itself.

  38. Possible problem in algorithm • Modify AG • Adding a edge into IN • Contract the edge 1 1 2 2 3 3

  39. Possible problem in algorithm • Modify AG • Add a edge into OUT • Delete the edge 1 1 2 2 3 3

  40. Modify the fundamental cycle • After we exchange the edges, the fundamental cycles of this tree would change • We need to modify the fundamental cycles e1 e1 e1 e2 e2 e2 f f f e3 e3 e3

  41. Modify the fundamental cycle • Author uses the data structure C to maintain the fundamental cycles • C maintains the fundamental cycles corresponding to the current tree • There are 3 operations to construct computation tree: • After deleting edge ei in AG, merge the fundamental cycles contain ei • After contracting edge e in AG, contract edge e in C • Delete the nontree edge for the last son

  42. Merge the fundamental cycles • Use 4 pointer to modify the cycles • This operation takes time proportional to the size of resulting cycle

  43. Contract edge in C • This operation takes time proportional to fundamental cycles containing the contracted edge

  44. Delete the nontree edge in C • If the nontree edge is a part of a multiedge, then do nothing • else delete the fundamental cycle containing the nontree edge • This operation takes time proportional to the size of its fundamental cycle

  45. AG and C • When some edge e is added to set IN: • Contract e in AG and C • When some edge e is added to set OUT: • Delete e in AG and C • Merge the fundamental cycles containing e

  46. Lemma 1.2 • The algorithm done at each node A of C(G)is O(|s(A)|+|g(A)|) • Where s(A) is the set of sons of A in C(G), g(A) is the set of sons in C’(G) of nodes in s(A)

  47. Proof • When replace tree edge ei by f , We need to • Contract f in AG: constant time • merge fundamental cycles in C containing ei:it takes time proportional to the sum size of resulting cycle ( O(|g(A)|) ) • Contract ei in C: it takes time proportional to the number of cycles contain ei ( O(|g(A)|) ) • Contract eiin AG: it takes time proportional to the number of multiedges incident to the endpoints of ei( O(|g(A)|) )

  48. Proof • Before operating the node is the last son, then • Delete f in AG: constant time • Delete f in C: time proportional to the size of its fundamental cycle( O(s(A)) ) • Every node takes O(|s(A)|+|g(A)|) time

  49. Theorem 1.3 • All spanning trees can be correctly generated in O( N + V + E ) time by Algorithm 1 • [Proof] • First, construct a spanning tree and setup it’s data structure • require O( V + E ) time • Every node in computation tree C(G) takes O(|s(A)|+|g(A)|) time • Summing overall nodes of C(G) is O(N)

  50. Theorem 1.4 • The space requirement of the spanning tree enumeration Algorithm 1 is O( V2E ) • [Proof] • At each node of C(G), take O( VE ) space • The height of C’(G) is at most V … … …

More Related