antisplice-0.14.0.0: An engine for text-based dungeons.

Safe HaskellNone

Game.Antisplice.Utils.Graph

Description

Provides a general graph.

Synopsis

Documentation

newtype NodeId Source

Phantom type for a node ID

Constructors

NodeId Int 

data Graph a b c Source

A general graph

Constructors

Graph 

Fields

nodes :: AVL (Node a)
 
edges :: [Edge b c]
 
nextId :: NodeId
 

Instances

None (Graph a b c) 

data Node a Source

A node for the graph

Constructors

Node 

Fields

nodeMarked :: Bool
 
nodeContent :: a
 
nodeId :: NodeId
 

Instances

Show a => Show (Node a) 
Indexable (Node a) NodeId (Node a) 

data Edge b c Source

An edge for the graph

Constructors

Edge 

Fields

fromNode :: NodeId
 
toNode :: NodeId
 
weight :: Int
 
label :: b
 
content :: c
 

Instances

Show b => Show (Edge b c) 

incId :: NodeId -> NodeIdSource

Increment a NodeId

emptyGraph :: Graph a b cSource

An empty graph

addNode :: a -> Graph a b c -> Graph a b cSource

Add a node to the graph

addNode' :: a -> Graph a b c -> (NodeId, Graph a b c)Source

Add a node to the graph and also return its ID

addNodes :: [a] -> Graph a b c -> Graph a b cSource

Add a bunch of nodes

addNodes' :: [a] -> Graph a b c -> ([NodeId], Graph a b c)Source

Add a bunch of nodes and also return their IDs

allNodes :: Graph a b c -> [Node a]Source

Return all nodes

rootNode :: Graph a b c -> NodeIdSource

Return the node in the AVL tree's root

addEdge :: NodeId -> NodeId -> Int -> b -> c -> Graph a b c -> Graph a b cSource

Add a unidirectional edge to the graph (provide both nodes, a weight and a label)

addEdge' :: Edge b c -> Graph a b c -> Graph a b cSource

Add a unidirectional edge to the graph (provide the Edge)

addMutualEdge :: NodeId -> NodeId -> Int -> b -> c -> Graph a b c -> Graph a b cSource

Add a bidirectional edge to the graph (provide both nodes, a weight and a label)

addEdges :: [(NodeId, NodeId, Int, b, c)] -> Graph a b c -> Graph a b cSource

Add a bunch of edges unidirectionally (provide both nodes, a weight and a label)

addEdges' :: [Edge b c] -> Graph a b c -> Graph a b cSource

Add a bunch of edges unidirectionally (provide the Edges)

addMutualEdges :: [(NodeId, NodeId, Int, b, c)] -> Graph a b c -> Graph a b cSource

Add a bunch of edges bidirectionally (provide both nodes, a weight and a label)

getNode :: NodeId -> Graph a b c -> aSource

Get the node's content from its ID

getNode' :: NodeId -> Graph a b c -> Node aSource

Get the Node object from its ID

setNode :: NodeId -> a -> Graph a b c -> Graph a b cSource

Set the node's content by its ID

markNode :: NodeId -> Graph a b c -> Graph a b cSource

Mark a node by its ID

followEdge :: Eq b => NodeId -> b -> Graph a b c -> Maybe NodeIdSource

Follow an edge by its source node and label

queryEdge :: Eq b => NodeId -> b -> Graph a b c -> Maybe cSource

Query an edge's content

listEdges :: NodeId -> Graph a b c -> [(b, c, NodeId)]Source

List all edges from the given node