goyalarchit / graph-extra / Graph.Extra

This module implements additional convenience functions to work with the elm-community/graph

Utility

alongAnyEdges : Graph.NodeContext n e -> List Graph.NodeId

A good default for selecting neighbors that go along outgoing edges or follow along incoming edges:

Algorithms

bellmanFord : Graph.NodeId -> (Graph.Edge e -> number) -> Graph n e -> Result String (Dict Graph.NodeId ( number, List Graph.NodeId ))

An implementation of bellman ford algorithm, for finding shortest path between single source and all vertices. Returns them as a dictionary or an error in Result type.

Note: You may know error occurs in case there is a negative weight cycle.

kruskal : (Graph.Edge e -> number) -> Graph n e -> Graph n e

This algorithms returns the minimum spanning tree for the given graph using Kruskal's algorithm.

Note : 1. Returns Minimum Spanning Arborescence in case of directed graph 2. Assumes directed graphs, so if you want MST on undirected graph, pass (Graph.symmetricClosure graph)