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

Safe HaskellNone
LanguageHaskell2010

Math.Grads.GenericGraph

Description

Module that provides abstract implementation of graph-like data structure GenericGraph and many helpful functions for interaction with GenericGraph.

Synopsis

Documentation

data GenericGraph v e Source #

Generic undirected graph which stores elements of type v in its vertices (e.g. labels, atoms, states etc) and elements of type e in its edges (e.g. weights, bond types, functions over states etc). Note that loops and multiple edges between two vertices are allowed.

Constructors

GenericGraph 

Fields

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 #

Functor (GenericGraph v) Source # 
Instance details

Defined in Math.Grads.GenericGraph

Methods

fmap :: (a -> b) -> GenericGraph v a -> GenericGraph v b #

(<$) :: a -> GenericGraph v b -> GenericGraph v a #

(Ord v, Eq v, Show v, Show e) => Show (GenericGraph v e) Source # 
Instance details

Defined in Math.Grads.GenericGraph

Generic (GenericGraph v e) Source # 
Instance details

Defined in Math.Grads.GenericGraph

Associated Types

type Rep (GenericGraph v e) :: Type -> Type #

Methods

from :: GenericGraph v e -> Rep (GenericGraph v e) x #

to :: Rep (GenericGraph v e) x -> GenericGraph v e #

Ord v => Semigroup (GenericGraph v e) Source # 
Instance details

Defined in Math.Grads.GenericGraph

Methods

(<>) :: GenericGraph v e -> GenericGraph v e -> GenericGraph v e #

sconcat :: NonEmpty (GenericGraph v e) -> GenericGraph v e #

stimes :: Integral b => b -> GenericGraph v e -> GenericGraph v e #

(Ord v, Eq v) => Monoid (GenericGraph v e) Source # 
Instance details

Defined in Math.Grads.GenericGraph

(Ord v, Eq e, ToJSON v, ToJSON e) => ToJSON (GenericGraph v e) Source # 
Instance details

Defined in Math.Grads.GenericGraph

(Ord v, Eq e, FromJSON v, FromJSON e) => FromJSON (GenericGraph v e) Source # 
Instance details

Defined in Math.Grads.GenericGraph

type Rep (GenericGraph v e) Source # 
Instance details

Defined in Math.Grads.GenericGraph

type Rep (GenericGraph v e) = D1 (MetaData "GenericGraph" "Math.Grads.GenericGraph" "math-grads-0.1.6.7-9Jnt71iCAtf8PLj7X7SLHO" False) (C1 (MetaCons "GenericGraph" PrefixI True) (S1 (MetaSel (Just "gIndex") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Array Int v)) :*: (S1 (MetaSel (Just "gRevIndex") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map v Int)) :*: S1 (MetaSel (Just "gAdjacency") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Array Int [(Int, e)])))))

addEdges :: Ord v => GenericGraph v e -> [(Int, Int, e)] -> GenericGraph v e Source #

Add given edges to the graph.

addVertices :: Ord v => GenericGraph v e -> [v] -> GenericGraph v e Source #

Add given vertices to graph.

applyG :: ([(Int, e1)] -> [(Int, e2)]) -> GenericGraph v e1 -> GenericGraph v e2 Source #

fmap which acts on adjacency lists of each vertex.

applyV :: Ord v2 => (v1 -> v2) -> GenericGraph v1 e -> GenericGraph v2 e Source #

fmap which acts on vertices.

getVertices :: GenericGraph v e -> [v] Source #

Get all vertices of the graph.

getEdge :: GenericGraph v e -> Int -> Int -> e Source #

Get edge from graph, which starting and ending indices match given indices.

isConnected :: GenericGraph v e -> Int -> Int -> Bool Source #

Check that two vertices with given indexes have edge between them.

removeEdges :: Ord v => GenericGraph v e -> [(Int, Int)] -> GenericGraph v e Source #

Remove given edges from the graph. Note that isolated vertices are allowed. This will NOT affect indexation.

removeVertices :: Ord v => GenericGraph v e -> [Int] -> GenericGraph v e Source #

Remove given vertices from the graph. Note that indexation will be CHANGED. Be careful with !. and ?. operators.

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

Safe extraction from the graph. If there is no requested key in it, empty list is returned.

safeIdx :: GenericGraph v e -> Int -> [Int] Source #

Safe extraction from the graph. If there is no requested key in it, empty list is returned.

subgraph :: Ord v => GenericGraph v e -> [Int] -> GenericGraph v e Source #

Get subgraph on given vertices. Note that indexation will be CHANGED. Be careful with !. and ?. operators.

subgraphWithReindex :: Ord v => GenericGraph v e -> [Int] -> (Bimap Int Int, GenericGraph v e) Source #

Get subgraph on given vertices and mapping from old toKeep indices to new indices of resulting subgraph.

sumGraphs :: Ord v => GenericGraph v e -> GenericGraph v e -> GenericGraph v e Source #

Returns graph that is the sum of two given graphs assuming that they are disjoint.

typeOfEdge :: Ord v => GenericGraph v e -> Int -> Int -> e Source #

Returns type of edge with given starting and ending indices.