Module

Data.Graph.Types

Package
purescript-hylograph-graph
Repository
afcondon/purescript-hylograph-graph

Graph Types

Core data structures for weighted graphs.

#NodeId Source

newtype NodeId

Node identifier

Constructors

Instances

#Edge Source

type Edge = { from :: NodeId, to :: NodeId, weight :: Number }

Weighted edge

#EdgeId Source

newtype EdgeId

Edge identifier (ordered pair of nodes)

Constructors

Instances

#Graph Source

newtype Graph

Graph with nodes and weighted edges Stored as adjacency list for efficient neighbor lookup

Constructors

#Path Source

type Path = Array NodeId

A path is a sequence of nodes

#mkGraph Source

mkGraph :: Array NodeId -> Array Edge -> Graph

Create a graph from nodes and edges

#nodes Source

nodes :: Graph -> Array NodeId

Get all nodes

#edges Source

edges :: Graph -> Array Edge

Get all edges

#neighbors Source

neighbors :: NodeId -> Graph -> Array { neighbor :: NodeId, weight :: Number }

Get neighbors of a node with their edge weights

#edgeWeight Source

edgeWeight :: NodeId -> NodeId -> Graph -> Maybe Number

Get weight of a specific edge

#updateWeight Source

updateWeight :: NodeId -> NodeId -> Number -> Graph -> Graph

Update the weight of an edge

#nodePositions Source

nodePositions :: Graph -> Map NodeId { x :: Number, y :: Number }

Get/set node positions (for visualization)