# Maximum Possible Edge Disjoint Spanning Tree From a Complete Graph in C++

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

Best Seller

66 Lectures 5.5 hours

Suppose we have a complete graph; we have to count number of Edge Disjoint Spanning trees. The Edge Disjoint Spanning trees are spanning trees, where no two trees in the set have an edge in common. Suppose the N (number of vertices) is 4, then output will be 2. The complete graph using 4 vertices is like below −

Two edge disjoint spanning trees are like −

The maximum number of edge disjoint spanning tree from a complete graph, with N vertices will be $[\frac{n}{2}]$

## Example

#include <iostream>
#include <cmath>
using namespace std;
int maxEdgeDisjointSpanningTree(int n){
return floor(n/2);
}
int main() {
int n = 4;
cout << "Maximum Edge Disjoint Spanning Tree: " <<
maxEdgeDisjointSpanningTree(n);
}

## Output

Maximum Edge Disjoint Spanning Tree: 2
Updated on 21-Oct-2019 12:25:24