Minimal network | Euler 107

This problem involves a graph algorithm which is known as Kruskal's algorithm which tries to minimize the sum of values associated with vertices in a graph.

Edges are sorted and then added to a list if it does not violate the rule of minimal graph, which has no closed loops. For this the item is checked whether the vertices are already there in the completed vertices.

This is a simple algorithm and is implemented below with python language. This is a link for the input text file.

Comments

Popular Posts