math-grads-0.1.6.7: Library containing graph data structures and graph algorithms

Safe HaskellSafe
LanguageHaskell2010

Math.Grads.Graph

Description

Module that provides Graph type class and several useful functions for interaction with Graphs.

Synopsis

Documentation

type EdgeList e = [GraphEdge e] Source #

Type alias for list of GraphEdges.

class Graph g where Source #

Type class that gives data structure properties of graph.

Minimal complete definition

fromList, toList, vCount, (!>), (!.), (?>), (?.)

Methods

fromList :: (Ord v, Eq v) => ([v], [GraphEdge e]) -> g v e Source #

Construct a graph from list of vertices and edges.

toList :: (Ord v, Eq v) => g v e -> ([v], [GraphEdge e]) Source #

Get a list of all vertices and edges from the graph.

vCount :: g v e -> Int Source #

Get the number of vertices.

(!>) :: (Ord v, Eq v) => g v e -> v -> [(v, e)] infixl 9 Source #

Unsafe get adjacent vertices.

(!.) :: g v e -> Int -> [(Int, e)] infixl 9 Source #

Unsafe get adjacent indices.

(?>) :: (Ord v, Eq v) => g v e -> v -> Maybe [(v, e)] infixl 9 Source #

Safe get adjacent vertices.

(?.) :: g v e -> Int -> Maybe [(Int, e)] infixl 9 Source #

Safe get adjacent indices.

incident :: (Ord v, Eq v) => g v e -> v -> [(v, v, e)] Source #

Get a list of edges starting at given vertex.

safeIncident :: (Ord v, Eq v) => g v e -> v -> Maybe [(v, v, e)] Source #

Safe get a list of edges starting at given vertex.

incidentIdx :: Eq e => g v e -> Int -> [GraphEdge e] Source #

Get a list of index edges starting at given vertex.

safeIncidentIdx :: Eq e => g v e -> Int -> Maybe [GraphEdge e] Source #

Safe get a list of index edges starting at given vertex.

Instances
Graph GenericGraph Source # 
Instance details

Defined in Math.Grads.GenericGraph

Methods

fromList :: (Ord v, Eq v) => ([v], [GraphEdge e]) -> GenericGraph v e Source #

toList :: (Ord v, Eq v) => GenericGraph v e -> ([v], [GraphEdge e]) Source #

vCount :: GenericGraph v e -> Int Source #

(!>) :: (Ord v, Eq v) => GenericGraph v e -> v -> [(v, e)] Source #

(!.) :: GenericGraph v e -> Int -> [(Int, e)] Source #

(?>) :: (Ord v, Eq v) => GenericGraph v e -> v -> Maybe [(v, e)] Source #

(?.) :: GenericGraph v e -> Int -> Maybe [(Int, e)] Source #

incident :: (Ord v, Eq v) => GenericGraph v e -> v -> [(v, v, e)] Source #

safeIncident :: (Ord v, Eq v) => GenericGraph v e -> v -> Maybe [(v, v, e)] Source #

incidentIdx :: Eq e => GenericGraph v e -> Int -> [GraphEdge e] Source #

safeIncidentIdx :: Eq e => GenericGraph v e -> Int -> Maybe [GraphEdge e] Source #

type GraphEdge e = (Int, Int, e) Source #

GraphEdge is just triple, containing index of starting vertex of edge, index of ending vertex of edge and edge's type.

changeIndsEdge :: (Int -> Int) -> GraphEdge e -> GraphEdge e Source #

Given transformation of edge's indices transforms GraphEdge.

changeTypeEdge :: (e1 -> e2) -> GraphEdge e1 -> GraphEdge e2 Source #

Given transformation of edge types transforms GraphEdge.

edgeType :: GraphEdge e -> e Source #

Get edge's type from GraphEdge.