Advanced maths

Edge disjoint spanning tree packing calculator with tree witnesses

Pack as many edge-disjoint spanning trees as possible and inspect every tree witness.

Your numbers

One zero-based undirected edge per line; no loops or duplicate unordered pairs.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Pack as many edge-disjoint spanning trees as possible and inspect every tree witness. A partition-based upper bound checks the maximum instead of confusing the number of available trees with the size of a disjoint collection.

THE FORMULAmax k such that T1,…,Tk are spanning trees with pairwise disjoint edge sets; k≤floor(crossing(P)/(blocks(P)−1)) for every partition P.

A worked example

The complete graphK4 has six edges and each spanning tree needs three. Trees{0–1,1–2,2–3} and{0–2,0–3,1–3} share no edges, so two can be packed. Six divided by three also gives the upper bound two.

Good to know

Simple undirected graph2–8 vertices,≤20 edges. Exhaustive spanning-tree enumeration plus Nash-Williams partition bound and disjoint packing witness. Search capped at2000000 tree/packing states; failure to construct the bound witness returns an error,no unsupported maximum.

A collection can share vertices but not edges

Every packed tree spans all declared vertices and is connected without cycles. Different trees necessarily use the same vertices, but no undirected host edge may appear in two trees in the collection.

The maximum collection size is different from the total count of spanning trees. A graph may have many alternative trees while all of them depend on a single bridge, limiting the number of edge-disjoint trees to one.

Six edges support two trees on four vertices0123K4:6 available edgesTwo trees,3 edges eachNo edge is shared
Scroll across to see the full diagram.
The complete graphK4 has six edges and each spanning tree needs three. Trees{0–1,1–2,2–3} and{0–2,0–3,1–3} share no edges, so two can be packed. Six divided by three also gives the upper bound two.

Compare this with the Spanning tree count calculator using a graph Laplacian. Counting trees does not find a maximum collection sharing no edges.

Declare edges as available unit resources

Enter a simple undirected edge list with zero-based endpoints. Each edge can be assigned to at most one tree. Parallel links and edge capacities greater than one are not modeled by repeating rows.

An isolated vertex or disconnected component can prevent even one spanning tree. Costs and root orientations are also absent from this problem: the solver maximizes the number of topological trees, not a weighted objective or a collection of directed arborescences.

Partitions give an exact upper bound

A spanning tree must cross any partition into r vertex blocks at least r−1 times. Therefore k edge-disjoint spanning trees require at least k(r−1) available crossing edges for every partition.

The Nash-Williams–Tutte theorem makes the minimum of these integer partition ratios the exact packing number. The implementation enumerates supported partitions and then constructs that many disjoint trees, pairing a theoretical bound with concrete positive witnesses.

Six edges support two trees on four vertices

The displayedK4 permits a path0–1–2–3 as one tree. Its three unused edges0–2,0–3,1–3 form another connected acyclic spanning subgraph, so they are a second tree.

Both trees use three edges and together exhaust the six available edges. The simple total-edge bound already limits any packing to floor(6/3)=2. Thus the two witnesses meet an independently obvious upper bound in this default example.

Inspect both the tree and partition certificates

For each tree, count n−1 edges and verify connectivity across all vertices. Then compare the edge lists pairwise. These checks establish that the claimed number of trees is genuinely feasible.

A partition witness can explain a tighter obstruction than the total-edge count, such as two dense regions joined by few links. When the total-edge bound is already tight, the returned explicit partition witness may be empty because no improving partition was needed.

A capped witness search cannot certify success

The solver bounds spanning-tree generation and subsequent disjoint packing search. If it cannot finish constructing the partition-bound number of trees within the cap, it raises an error rather than displaying an unverified theorem-derived answer alone.

The vertex bound also controls the number of set partitions. These restrictions make exact educational examples practical, but do not claim a scalable matroid-union implementation for large graphs or a guarantee that every supported dense case finishes before the cap.

Separate redundancy from physical independence

Disjoint tree collections can organize alternative link sets, but the mathematical meaning of independence is strictly edge disjointness. Trees may share every station, region and physical conduit represented only indirectly by graph vertices.

Consequently two packed trees do not automatically guarantee resilience to vertex failures or common-cause failures. If a network application needs those protections, define the relevant failure resources explicitly before interpreting this topological certificate as operational redundancy.

A few questions, answered

Do the trees need different vertices?

No. Every tree spans the same vertices; only their edge sets must be disjoint.

Is this the total number of spanning trees?

No. It is the maximum number that can be chosen without sharing edges.

What does the partition bound prove?

It bounds how many trees can cross all vertex-block separations using the available edges.

Why can a witness search return an error?

A finite search cap can be reached before the maximum-size disjoint collection is reconstructed.

Find your calculator

Start typing to explore the library.