Skip to content

EricSzla/MST-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MST-Algorithm

Implementation of the Prim List - MST Algorithm for the graph loaded from a txt file.
Prim List is an algorithm that finds a minimum spanning tree for a weighted undirected graph.
An undirected graph means that all the edges in the graph are bidirectional.
The Algorithm finds a subset of edges that includes every vertex where the total weight of all edges in the tree is minimized.

Diagram

The diagram of a graph that I have used to present how the Algorithm works: Diagram 1

Graph representation in .txt

The following numbers in the text file are used to represent the graph:

6 9 0 ← This means: 6 = number of verices, 9 = number of edges
1 2 1
1 4 5
1 3 3
2 3 6
2 6 12
3 4 6
3 5 4
3 6 8
4 5 7
5 6 3

The numbers in the first column represent the vertice, the number in the second column represent vertice its connected to, and the numbers in the third column represent the weight e.g:
1 2 1 : Means A connects to B using weight 1

Adjacency Matrix

This is a simple representation of the graph using Adjacency Matrix. Adjacency Matrix

Adjacency Lists Diagram

This is a simple representation of the graph using Adjacency Lists Diagram. ListsDiagram1

The diagram indicates to which of other vertices each of the vertices is connected to and shows the weight associated with the edge, e.g.: A is connected to B with the weight of 1 is represented as: LIstDiagram2

MST superimposed on the graph

MST

About

Implementation of the MST Algorithm for the graph loaded from a txt file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages