Skip to content
/ MST Public

Two Implementations of Minimal Spanning Trees

Notifications You must be signed in to change notification settings

leanne73/MST

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

MST

Two Implementations of Minimal Spanning Trees: Kruskal & Prim

Included are two basic implementations of MST algorithms.

KruskalMST takes graphs in the form of a string of ints where the first int is the number of vertices followed by a sequence of edges represented in the form vertex1,vertex2,edgeWeight. Graphs are assumed to be undirected.

Example: 4 1,2,3 2,3,5 3,0,4

This would denote a graph with 4 vertices [0..3] and 3 edges where w(1,2)=3 ; w(2,3)=5 ; w(3,0)=4 if w is the weight function.

PrimMST takes graphs formatted in the the same way except that an additional single integer follows the number of vertices. This number specifies which vertex is to be the root of the growing tree.

Example: 4 1 1,2,3 2,3,5 3,0,4

This indicates the same graph as above with the specified root vertex being 1.

About

Two Implementations of Minimal Spanning Trees

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages