Copyright | (c) Ivan Lazar Miljenovic 2009 |
---|---|
License | 2-Clause BSD |
Maintainer | Ivan.Miljenovic@gmail.com |
Safe Haskell | None |
Language | Haskell98 |
This module defines the various types and classes utilised by the Graphalyze library.
- data GraphData n e = GraphData {
- graph :: AGr n e
- wantedRootNodes :: NGroup
- directedData :: Bool
- unusedRelationships :: [Rel n e]
- type AGr n e = Gr n e
- type Rel n e = (n, n, e)
- type NGroup = [Node]
- type LNGroup a = [LNode a]
- wantedRoots :: GraphData n e -> LNGroup n
- addRoots :: GraphData n e -> NGroup -> GraphData n e
- addRootsBy :: (LNode n -> Bool) -> GraphData n e -> GraphData n e
- applyAlg :: (AGr n e -> a) -> GraphData n e -> a
- applyDirAlg :: (Bool -> AGr n e -> a) -> GraphData n e -> a
- mergeUnused :: (Ord n, Ord e) => GraphData n e -> GraphData n e
- removeUnused :: GraphData n e -> GraphData n e
- updateGraph :: (AGr a b -> AGr c d) -> GraphData a b -> GraphData c d
- updateGraph' :: (Bool -> AGr a b -> AGr c d) -> GraphData a b -> GraphData c d
- mapAllNodes :: (Ord a, Ord e, Ord b) => (a -> b) -> GraphData a e -> GraphData b e
- mapNodeType :: (Ord a, Ord b, Ord e) => (a -> b) -> (a -> b) -> GraphData a e -> GraphData b e
- class (Ord (Cluster cl), ToGraphID (Cluster cl)) => ClusterLabel cl where
- data GraphID :: *
- data GenCluster a = GC {}
- data PosLabel a = PLabel {}
Graph specialization.
Represents information about the graph being analysed.
GraphData | |
|
Functions on GraphData
.
wantedRoots :: GraphData n e -> LNGroup n Source #
The expected roots in the data to be analysed.
addRoots :: GraphData n e -> NGroup -> GraphData n e Source #
Add extra expected root nodes. No checks are made that these
are valid Node
values.
addRootsBy :: (LNode n -> Bool) -> GraphData n e -> GraphData n e Source #
Use a filtering function to find extra root nodes to add.
applyAlg :: (AGr n e -> a) -> GraphData n e -> a Source #
Apply an algorithm to the data to be analysed.
mergeUnused :: (Ord n, Ord e) => GraphData n e -> GraphData n e Source #
Merge the unusedRelationships
into the graph by adding the
appropriate nodes.
removeUnused :: GraphData n e -> GraphData n e Source #
Used to set
. This is of use when
they are unneeded or because there is no sensible mapping
function to use when applying a mapping function to the nodes in
the graph.unusedRelationships
= []
updateGraph :: (AGr a b -> AGr c d) -> GraphData a b -> GraphData c d Source #
Replace the current graph by applying a function to it. To
ensure type safety, removeUnused
is applied.
updateGraph' :: (Bool -> AGr a b -> AGr c d) -> GraphData a b -> GraphData c d Source #
Replace the current graph by applying a function to it, where the
function depends on whether the graph is directed (True
) or
undirected (False
). To ensure type safety, removeUnused
is
applied.
mapAllNodes :: (Ord a, Ord e, Ord b) => (a -> b) -> GraphData a e -> GraphData b e Source #
Apply a function to all the data points.
This might be useful in circumstances where you want to reduce
the data type used to a simpler one, etc. The function is also
applied to the datums in unusedRelationships
.
mapNodeType :: (Ord a, Ord b, Ord e) => (a -> b) -> (a -> b) -> GraphData a e -> GraphData b e Source #
Apply the first function to nodes in the graph, and the second
function to those unknown datums in unusedRelationships
.
As a sample reason for this function, it can be used to apply a
two-part constructor (e.g. Left
and Right
from Either
) to
the nodes such that the wanted and unwanted datums can be
differentiated before calling mergeUnused
.
Clustering graphs based on their node labels.
class (Ord (Cluster cl), ToGraphID (Cluster cl)) => ClusterLabel cl where Source #
These types and classes represent useful label types.
The class of outputs of a clustering algorithm. This class is
mainly used for visualization purposes, with the Ord
instance
required for grouping. Instances of this class are intended for
use as the label type of graphs.
Graph label types.
data GenCluster a Source #
A generic cluster-label type.
Eq a => Eq (GenCluster a) Source # | |
Show a => Show (GenCluster a) Source # | |
ClusterLabel (GenCluster a) Source # | |
type Cluster (GenCluster a) Source # | |
type NodeLabel (GenCluster a) Source # | |
Label type for storing node positions. Note that this isn't an
instance of ClusterLabel
since there's no clear indication on
which cluster a node belongs to at this stage.