goyalarchit/graph-extra/1.0.1

Graph.Extra

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

Utility

alongAnyEdges : NodeContext n e -> List NodeId

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

Algorithms

NodeId
-> (Edge e -> number)
-> Graph n e
-> Result String (Dict NodeId ( number, List 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 : (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)