libgraph-1.14: Store and manipulate data in a graph.

Safe HaskellSafe
LanguageHaskell2010

Data.Graph.Libgraph

Synopsis

Documentation

data Graph vertex arc Source #

Constructors

Graph 

Fields

Instances

Generic (Graph vertex arc) Source # 

Associated Types

type Rep (Graph vertex arc) :: * -> * #

Methods

from :: Graph vertex arc -> Rep (Graph vertex arc) x #

to :: Rep (Graph vertex arc) x -> Graph vertex arc #

type Rep (Graph vertex arc) Source # 
type Rep (Graph vertex arc) = D1 (MetaData "Graph" "Data.Graph.Libgraph.Core" "libgraph-1.14-FU1vyAFOlTG1NSc3tKKMcU" False) (C1 (MetaCons "Graph" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "root") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 vertex)) ((:*:) (S1 (MetaSel (Just Symbol "vertices") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [vertex])) (S1 (MetaSel (Just Symbol "arcs") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Arc vertex arc])))))

data Arc vertex arc Source #

Constructors

Arc 

Fields

Instances

(Eq arc, Eq vertex) => Eq (Arc vertex arc) Source # 

Methods

(==) :: Arc vertex arc -> Arc vertex arc -> Bool #

(/=) :: Arc vertex arc -> Arc vertex arc -> Bool #

(Show arc, Show vertex) => Show (Arc vertex arc) Source # 

Methods

showsPrec :: Int -> Arc vertex arc -> ShowS #

show :: Arc vertex arc -> String #

showList :: [Arc vertex arc] -> ShowS #

Generic (Arc vertex arc) Source # 

Associated Types

type Rep (Arc vertex arc) :: * -> * #

Methods

from :: Arc vertex arc -> Rep (Arc vertex arc) x #

to :: Rep (Arc vertex arc) x -> Arc vertex arc #

type Rep (Arc vertex arc) Source # 
type Rep (Arc vertex arc) = D1 (MetaData "Arc" "Data.Graph.Libgraph.Core" "libgraph-1.14-FU1vyAFOlTG1NSc3tKKMcU" False) (C1 (MetaCons "Arc" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "source") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 vertex)) ((:*:) (S1 (MetaSel (Just Symbol "target") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 vertex)) (S1 (MetaSel (Just Symbol "arc") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 arc)))))

(-->) :: vertex -> vertex -> SimpleArc vertex Source #

Create an arc between two vertices.

succs :: Eq vertex => Graph vertex arc -> vertex -> [vertex] Source #

Direct successors of a vertex.

preds :: Eq vertex => Graph vertex arc -> vertex -> [vertex] Source #

Direct predecessors of a vertex.

isSucc :: Eq vertex => Graph vertex arc -> vertex -> vertex -> Bool Source #

Is first vertex a successor of second?

isPred :: Eq vertex => Graph vertex arc -> vertex -> vertex -> Bool Source #

Is first vertex a predecessor of second?

mapGraph :: (a -> b) -> Graph a c -> Graph b c Source #

mapArcs :: (a -> b) -> Graph c a -> Graph c b Source #

data Dfs vertex arc Source #

Instances

(Eq vertex, Show vertex) => Show (Dfs vertex arc) Source # 

Methods

showsPrec :: Int -> Dfs vertex arc -> ShowS #

show :: Dfs vertex arc -> String #

showList :: [Dfs vertex arc] -> ShowS #

getDfs :: Eq vertex => Graph vertex arc -> Dfs vertex arc Source #

Walk graph in depth-first order and number the vertices.

getEdgetype :: (Eq vertex, Show vertex) => Dfs vertex arc -> Arc vertex arc -> EdgeType Source #

The EdgeType of an Arc.

getPreorder :: Dfs vertex arc -> [vertex] Source #

Get list of vertices in the order they were visited by the depth-first search.

getPostorder :: Dfs vertex arc -> [vertex] Source #

Get list of vertices in the order they were last visited by the depth-first search.

isAncestor :: (Eq vertex, Show vertex) => Dfs vertex arc -> vertex -> vertex -> Maybe Bool Source #

Is first vertex a (recursive) parent of second vertex? May fail when one of the vertices is unreachable from the root.

data Domsets vertex arc Source #

Instances

(Eq vertex, Show vertex) => Show (Domsets vertex arc) Source # 

Methods

showsPrec :: Int -> Domsets vertex arc -> ShowS #

show :: Domsets vertex arc -> String #

showList :: [Domsets vertex arc] -> ShowS #

getDomsets :: Eq vertex => Graph vertex arc -> Domsets vertex arc Source #

Compute dominator sets. N.B. currently a naive algorithm is implemented with time-complexity O(vertex^2).

getDominators :: Eq vertex => vertex -> Domsets vertex arc -> [vertex] Source #

Vertices dominating the vertex given as argument.

data CycleTree vertex Source #

Constructors

CycleTree vertex [CycleTree vertex] 
Reducible vertex [CycleTree vertex] 
Irreducible [CycleTree vertex] 

Instances

Show vertex => Show (CycleTree vertex) Source # 

Methods

showsPrec :: Int -> CycleTree vertex -> ShowS #

show :: CycleTree vertex -> String #

showList :: [CycleTree vertex] -> ShowS #

getCycles :: Ord vertex => CycleNest vertex -> CycleTree vertex Source #

getRedHeaders :: CycleNest vertex -> [vertex] Source #

Entry vertices of reducible cycles.

dagify :: (Ord v, Eq a, Show v) => ([v] -> v) -> Graph v a -> Graph v a Source #

findFaulty :: (Ord v, Eq a, Show v) => (v -> Judgement) -> ([v] -> v) -> Graph v a -> [v] Source #

findFaulty_dag :: (Ord v, Eq a, Show v) => (v -> Judgement) -> Graph v a -> [v] Source #

next_step :: Eq v => Graph v a -> (v -> Judgement) -> v Source #

next_daq :: Ord v => Graph v a -> (v -> Judgement) -> v Source #

showWith :: Eq vertex => Graph vertex arc -> (vertex -> (String, String)) -> (Arc vertex arc -> String) -> String Source #

Convert Graph to String with functions to show vertices and arcs.

display :: (Graph vertex arc -> String) -> Graph vertex arc -> IO () Source #

Invoke Graphviz and Imagemagick to display graph on screen.

collapse :: (Show v, Ord v, Eq a) => ([v] -> v) -> Graph v a -> Graph v a Source #

remove :: (Ord v, Show v) => Graph v a -> Graph v a Source #

treeDepth :: Ord v => Graph v a -> Int Source #

succCache :: Ord vertex => Graph vertex arc -> vertex -> [vertex] Source #

predCache :: Ord vertex => Graph vertex arc -> vertex -> [vertex] Source #