hbgl-0.1.0.0: A Haskell version of the Boost Graph Library

Safe HaskellNone

Data.Graph.Algorithms.Basic

Contents

Synopsis

Basic graph operations

grev :: (InspectableGraph gr, MutableGraph gr, VertexListGraph gr) => gr -> gr

Reverse the directions of all of the edges in the graph

undir :: (Eq (EdgeLabel gr), InspectableGraph gr, MutableGraph gr, VertexListGraph gr) => gr -> gr

Make the graph undirected. For every edge (A->B)_L (edge from A to B with label L), make a new edge (B->A)_L.

unlab :: forall gr1 gr2. (VertexListGraph gr1, InspectableGraph gr1, MutableGraph gr2, VertexLabel gr1 ~ VertexLabel gr2, EdgeLabel gr2 ~ ()) => gr1 -> gr2

Remove the labels from edges. This may result in duplicate edges; the resolution of those edges depends on the underlying graph implementation (i.e., whether or not multi-edges are permitted).

gsel

Arguments

:: (VertexListGraph gr, InspectableGraph gr) 
=> (Context gr -> Bool)

The predicate

-> gr

The graph

-> [Context gr] 

Return all of the contexts for which the predicate evaluates to True

Filtering operations

efilter

Arguments

:: (MutableGraph gr, InspectableGraph gr, VertexListGraph gr) 
=> (Edge gr -> Bool)

Edge condition

-> gr

Input graph

-> gr 

Filter edges from the graph, keeping those that meet the condition

elfilter

Arguments

:: (MutableGraph gr, InspectableGraph gr, VertexListGraph gr) 
=> (EdgeLabel gr -> Bool)

Edge label condition

-> gr

Input graph

-> gr 

Filter edges from the graph based on just the edge label

Simple predicates

hasLoop :: (VertexListGraph gr, InspectableGraph gr) => gr -> Bool

Test to see if the graph has a self loop on any vertex

isSimple :: (VertexListGraph gr, InspectableGraph gr) => gr -> Bool

Inverse of hasLoop

Tree operations

postorder :: Tree a -> [a]

postorderF :: [Tree a] -> [a]

preorder :: Tree a -> [a]

preorderF :: [Tree a] -> [a]