Graphalyze-0.15.0.0: Graph-Theoretic Analysis library.

Copyright (c) Ivan Lazar Miljenovic 2009 2-Clause BSD Ivan.Miljenovic@gmail.com None Haskell98

Data.Graph.Analysis.Types

Description

This module defines the various types and classes utilised by the Graphalyze library.

Synopsis

# Graph specialization.

data GraphData n e Source #

Represents information about the graph being analysed.

Constructors

 GraphData Fieldsgraph :: AGr n eWe use a graph type with no edge labels.wantedRootNodes :: NGroupThe expected root nodes in the graph.directedData :: BoolIs the data this graph represents directed in nature?unusedRelationships :: [Rel n e]Unused relationships (i.e. not in the actual graph). These are the edges containing nodes not in the graph.

Instances

 (Eq n, Ord e) => Eq (GraphData n e) Source # Methods(==) :: GraphData n e -> GraphData n e -> Bool #(/=) :: GraphData n e -> GraphData n e -> Bool # (Read e, Read n) => Read (GraphData n e) Source # MethodsreadsPrec :: Int -> ReadS (GraphData n e) #readList :: ReadS [GraphData n e] #readPrec :: ReadPrec (GraphData n e) # (Show e, Show n) => Show (GraphData n e) Source # MethodsshowsPrec :: Int -> GraphData n e -> ShowS #show :: GraphData n e -> String #showList :: [GraphData n e] -> ShowS #

type AGr n e = Gr n e Source #

An alias for the type of graph being used by default.

type Rel n e = (n, n, e) Source #

A relationship between two nodes with a label.

type NGroup = [Node] Source #

A grouping of Nodes.

type LNGroup a = [LNode a] Source #

A grouping of LNodes.

# 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.

applyDirAlg :: (Bool -> AGr n e -> a) -> GraphData n e -> a Source #

Apply an algorithm that requires knowledge about whether the graph is directed (True) or undirected (False) 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 unusedRelationships = []. 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.

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.

Minimal complete definition

Associated Types

type Cluster cl Source #

type NodeLabel cl Source #

Methods

cluster :: cl -> Cluster cl Source #

The cluster the node label belongs in.

nodeLabel :: cl -> NodeLabel cl Source #

The actual label.

Instances

 Source # Associated Typestype Cluster (GenCluster a) :: * Source #type NodeLabel (GenCluster a) :: * Source # Methods

data GraphID :: * #

A polymorphic type that covers all possible ID values allowed by Dot syntax. Note that whilst the ParseDot and PrintDot instances for String will properly take care of the special cases for numbers, they are treated differently here.

Constructors

 Str Text Num Number

Instances

 Methods(==) :: GraphID -> GraphID -> Bool #(/=) :: GraphID -> GraphID -> Bool # Methods(<) :: GraphID -> GraphID -> Bool #(<=) :: GraphID -> GraphID -> Bool #(>) :: GraphID -> GraphID -> Bool #(>=) :: GraphID -> GraphID -> Bool # Methods MethodsshowList :: [GraphID] -> ShowS # MethodsunqtListToDot :: [GraphID] -> DotCode #listToDot :: [GraphID] -> DotCode # Methods

# Graph label types.

data GenCluster a Source #

A generic cluster-label type.

Constructors

 GC Fieldsclust :: Int nLbl :: a

Instances

 Eq a => Eq (GenCluster a) Source # Methods(==) :: GenCluster a -> GenCluster a -> Bool #(/=) :: GenCluster a -> GenCluster a -> Bool # Show a => Show (GenCluster a) Source # MethodsshowsPrec :: Int -> GenCluster a -> ShowS #show :: GenCluster a -> String #showList :: [GenCluster a] -> ShowS # Source # Associated Typestype Cluster (GenCluster a) :: * Source #type NodeLabel (GenCluster a) :: * Source # Methods type Cluster (GenCluster a) Source # type Cluster (GenCluster a) = Int type NodeLabel (GenCluster a) Source # type NodeLabel (GenCluster a) = a

data PosLabel 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.

Constructors

 PLabel FieldsxPos :: Int yPos :: Int pnode :: Node plabel :: a

Instances

 Eq a => Eq (PosLabel a) Source # Methods(==) :: PosLabel a -> PosLabel a -> Bool #(/=) :: PosLabel a -> PosLabel a -> Bool # Show a => Show (PosLabel a) Source # MethodsshowsPrec :: Int -> PosLabel a -> ShowS #show :: PosLabel a -> String #showList :: [PosLabel a] -> ShowS #