460 likes | 600 Vues
This article presents a novel approach to generating minimum spanning trees (MSTs) in network graphs by employing efficient algorithms such as Prim's and Kruskal's. It highlights the importance of eliminating cycles and ensuring all routers are included while maintaining optimal complexity. Utilizing a greedy methodology, where the locally optimal choice leads to a globally optimal solution, this implementation ensures minimum cost while addressing loops and redundancy. The efficiency of disjoint set data structures and priority queues at each stage is analyzed for improving performance in dynamic networking environments.
E N D
MINIMUMSPANNING TREE A NEW APPROACH
BACKUP PATHS b c a d f e
THE PROBLEM Occurring of loops
EXISTING SOLUTIONS Prim’s algorithm Kruskal algorithm Both of them take time O(n lg n)
A SPANNING TREE • All the routers are included • Cycles are eliminated • Each router has knowledge of • some Spanning Tree
THE TASK Generating a Spanning Tree having least cost Different MST algorithms are used
THE CHALLENGE DESIGNING A MST ALGORITHM HAVING LEAST COMPLEXITY
Prerequisites • The algorithm must not • exceed the order O(n lg n) • , desirable. • It must be practically • implementable
KEY IDEA • GREEDY APPROACH • At every stage make a • locally optimal choice • Leads to globally optimal • solution
IMPLEMENTATION • Each router maintains 2 • data structures • A Priority Queue for all the • routers connected to it • A Disjoint Set for maintaining • set of connected routers
ON A GRAPH • Each vertex maintains a Min- • Priority Queue, based on a • key field • A Disjoint-Set data structure • is maintained
The algorithm - MBA The steps S<- NULL FOR EACH VERTEX, vV[G] MAINTAIN A MINIMUM PRIORITY QUEUE VG MAKE SET(v)
5. FOR EACH VERTEX V V[G] U <- EXTRACT-MIN (QV) IF(u,v) S S<- S U {(u,v)} FOR EACH EDGE (u,v) E(S) IF FIND-SET(u) ≠ FIND-SET(v) UNION(u,v)
12. FOR EACH EDGE, (u,v) E(G) IF FIND-SET(u)= FIND-SET(v) w(u,v)=∞ FOR EACH VERTEX, v V[G] u<- EXTRACT-MIN( QV) IF (u,v) S S<- S U {(u,v)}
IF FIND-SET (u)≠ FIND-SET (v) UNION (u,v) ELSE S<- MAX{(x,y)}, (xy) SET(u) RETURN S
WORKING 9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d 4 9 2 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 ∞ c b d 4 9 2 ∞ ∞ ∞ 14 e a 11 4 i 7 6 10 8 g f h 1 2 ∞ ∞
9 7 c b d ∞ 4 9 2 ∞ ∞ ∞ 14 e a 11 4 i 7 6 10 8 g f h 1 2 ∞ ∞
9 7 c b d ∞ 4 9 2 ∞ ∞ ∞ 14 e a 11 4 i 7 6 10 8 g f h 1 2 ∞ ∞
9 7 c b d ∞ 4 9 2 ∞ ∞ 14 e a 11 4 i 7 6 10 8 g f h 1 2
9 7 c b d ∞ 4 9 2 ∞ ∞ ∞ 14 e a 11 4 i 7 6 10 8 g f h 1 2 ∞ ∞
9 7 c b d ∞ 4 9 2 ∞ ∞ ∞ 14 e a 11 4 i 7 6 8 10 g f h 1 2 ∞ ∞
9 7 c b d ∞ 4 9 2 ∞ ∞ ∞ 14 e a 11 4 i 7 6 8 10 g f h 1 2 ∞ ∞
9 7 c b d ∞ 4 9 2 ∞ ∞ ∞ 14 e a 11 i 4 7 6 8 10 g f h 1 2 ∞ ∞
9 7 c b d ∞ 4 9 2 ∞ ∞ ∞ 14 e a 11 4 i 7 6 8 10 g f h 1 2 ∞ ∞
9 7 c b d ∞ 4 9 2 ∞ ∞ ∞ 14 e a 11 4 i 7 6 8 10 g f h 1 2 ∞ ∞
ANALYSIS • Running time depends upon • Implementation of Disjoint Set Data Structure • Implementation of Priority • Queue
ANALYSIS • Disjoint-Set uses : • Path Compression • Union by Rank • Priority Queue : • Min-Priority Queue
ANALYSIS • Time taken at each step : • Line 1 : O(1) • Lines 2 & 5 : O(V) • Make Set operation : O(V) • Build Heap : O(log2V) • For ‘V’ vertices : O(V log2V)
Extract – min : O(log2V) • For all vertices : O(V log2V) • for loops in lines 9-11 & 12-14 : • O(E)
Order till line 14 : O ( V log2V )
Same process is repeated once more Overall complexity : O ( V log2V )
NEWER DIMENSIONS WHEN USED WITH PARALLEL PROCESSORS O(E) CAN BE ACHIEVED
BACKUP PATHS CAN BE FOUND FASTER CYCLES CAN BE ELIMINATED MORE EFFICIENTLY