Hylograph Project Documentation

hylograph-graph

purescript-hylograph-graph

Graph algorithms and data structures for PureScript, designed for visualization.

Live interactive demo can be seen as part of the suite of Hylograph library demos. Click the screenshot below for The Honeycomb puzzle. (The puzzle carries its own breadth-first search and does not call this library; the Graph Decomposition Explorer is the demo that does.)

Honeycomb Puzzle Demo

Overview

This package provides graph algorithms with optional tracing for visualization, consolidating graph-related code from the Hylograph ecosystem.

Features

Graph Algorithms

Tree Utilities

Visualization Support

Installation

spago install hylograph-graph

Usage

Basic Pathfinding

import Data.Graph.Pathfinding (PathResult, shortestPath)
import Data.Graph.Types (Graph, NodeId(..), mkGraph)

myGraph :: Graph
myGraph = mkGraph
  [ NodeId "a", NodeId "b", NodeId "c" ]
  [ { from: NodeId "a", to: NodeId "b", weight: 1.0 }
  , { from: NodeId "b", to: NodeId "c", weight: 2.0 }
  ]

result :: PathResult
result = shortestPath (NodeId "a") (NodeId "c") myGraph

With Tracing (for visualization)

import Data.Graph.Pathfinding.Traced (TracedResult, shortestPathTraced)

traced :: TracedResult PathResult
traced = shortestPathTraced (NodeId "a") (NodeId "c") myGraph
-- traced.steps is the sequence of visits and edge explorations to animate

Modules

Part of Hylograph

This package is part of the Hylograph visualization ecosystem:

License

MIT