Algorithms for generating all spanning trees of undirected, directed and weighted graphs

  • Sanjiv Kapoor
  • H. Ramesh
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 519)


We present algorithms for enumerating all spanning trees in directed, undirected and weighted graphs. The algorithms use a search tree technique to construct a computation tree. The computation tree is used to output all the spanning trees by listing the relative differences between spanning trees rather than the entire spanning trees themselves. For the undirected case, both the construction and the listing of the trees are shown to require O(N+V+E) time for a graph with V vertices, E edges and N spanning trees. This algorithm is optimal and is based on exchanging non-tree edges with tree edges in a fundamental cycle. A similar exchange technique is used to construct the computation tree for a directed graph in O(NV+V3) time. The time for listing out the trees remains O(N). For a weighted graph, we show how to sort the spanning trees by weight using the computation tree in O(N log V+VE) time.


Span Tree Weighted Graph Computation Tree Tree Edge Fundamental Cycle 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. ([1])
    J. P. Char: Generation of trees, 2 trees and storage of master forests, IEEE Trans. Circuit Theory, CT-15, 1968.Google Scholar
  2. ([2])
    Harold N. Gabow: Two algorithms for generating weighted spanning trees in order, SIAM J. Comp., Vol 6, No. 1, March 1977.Google Scholar
  3. ([3])
    H. N. Gabow and E. W. Myers: Finding all spanning trees of directed and undirected graphs, SIAM J. Comp., Vol 7, No. 3, Aug 1978.Google Scholar
  4. ([4])
    W. Mayeda: Graph Theory, John Wiley, NY 1972.Google Scholar
  5. ([5])
    G. J. Minty: A simple algorithm for listing all trees of a graph, IEEE Trans. Circuit Theory, CT-12, 1965.Google Scholar
  6. ([6])
    R. C. Read and R. E. Tarjan: Bounds on backtrack algorithms for listing cycles, paths and spanning trees, Networks, 5, No. 3, 1975.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1991

Authors and Affiliations

  • Sanjiv Kapoor
    • 1
  • H. Ramesh
    • 1
  1. 1.Department of Computer ScienceIndian Institute of Technology Hauz KhasNew Delhi

Personalised recommendations