Boruvka

com.phasmidsoftware.gryphon.traverse.Boruvka
object Boruvka

Computes the minimum spanning tree of an undirected weighted graph using Borůvka's algorithm.

The algorithm (historically the oldest MST algorithm, 1926):

  1. Start with each vertex as its own component.
  2. For each component, find the minimum-weight edge crossing to another component.
  3. Add all such edges to the MST (merging components).
  4. Repeat until only one component remains.

Each round halves the number of components, giving O(E log V) overall complexity.

NOTE: this is a direct iterative algorithm and does not use the Visitor traversal engine. The per-component minimum-edge scan in each round is embarrassingly parallel and could be parallelised using parallel collections or futures (TODO).

NOTE: intended for undirected weighted graphs only.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Boruvka.type

Members list

Value members

Concrete methods

def mst[V, E : Monoid : Ordering](graph: UndirectedGraph[V, E]): Seq[Edge[V, E]]

Computes the MST of graph using Borůvka's algorithm.

Computes the MST of graph using Borůvka's algorithm.

Type parameters

E

the edge weight type; must have Monoid and Ordering.

V

the vertex attribute type.

Value parameters

graph

the undirected weighted graph.

Attributes

Returns

a Seq[Edge[V, E]] — the MST edges in order of addition, consistent with Kruskal.mst.