generateSpanningTre​es(A)

Find all spanning trees of a connected undirected graph.

You are now following this Submission

The function “generateSpanningTrees(A)” generates all spanning trees for the connected undirected simple graph that is described by the adjacency matrix A. It is an implementation of 'Algorithm S' on p. 464 of the book “The Art of Computer Programming”, Volume 4A (Combinatorial Algorithms, Part 1), by Donald E. Knuth. Furthermore, a function “getNumberSpanningTrees(A)” is included, which computes the total number of spanning trees using Kirchhoff's matrix tree theorem.

Cite As

Matthias Hotz (2026). generateSpanningTrees(A) (https://in.mathworks.com/matlabcentral/fileexchange/53787-generatespanningtrees-a), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0