packages feed

comfort-graph 0.0.2.1 → 0.0.3

raw patch · 3 files changed

+41/−23 lines, 3 filesdep +semigroupsPVP ok

version bump matches the API change (PVP)

Dependencies added: semigroups

API changes (from Hackage documentation)

+ Data.Graph.Comfort: adjacentEdgeSet :: (Edge e, Ord n) => Graph e n el nl -> n -> Set (e n)
+ Data.Graph.Comfort: instance (Data.Graph.Comfort.Edge edge, GHC.Classes.Ord node) => Data.Semigroup.Semigroup (Data.Graph.Comfort.Graph edge node edgeLabel nodeLabel)
+ Data.Graph.Comfort: predecessors :: (Edge e, Ord n) => Graph e n el nl -> n -> [n]
+ Data.Graph.Comfort: successors :: (Edge e, Ord n) => Graph e n el nl -> n -> [n]

Files

comfort-graph.cabal view
@@ -1,5 +1,5 @@ Name:                comfort-graph-Version:             0.0.2.1+Version:             0.0.3 Synopsis:            Graph structure with type parameters for nodes and edges Description:   This graph structure is based on "Data.Map"@@ -51,7 +51,7 @@ Cabal-Version:       >=1.10  Source-Repository this-  Tag:         0.0.2.1+  Tag:         0.0.3   Type:        darcs   Location:    http://hub.darcs.net/thielema/comfort-graph @@ -70,6 +70,7 @@     QuickCheck >=2.5 && <3,     containers >=0.4 && <0.6,     transformers >=0.5 && <0.6,+    semigroups >=0.1 && <1.0,     utility-ht >=0.0.10 && <0.1,     base >=4.5 && <5   Hs-Source-Dirs:      src
src/Data/Graph/Comfort.hs view
@@ -1,5 +1,5 @@ module Data.Graph.Comfort (-   -- * types+   -- * Types    Graph,    LabeledNode,    LabeledEdge,@@ -8,34 +8,35 @@    UndirEdge(UndirEdge), undirEdge,    EitherEdge(EDirEdge,EUndirEdge), -   -- * construction+   -- * Construction    empty, fromList, fromMap, -   -- * extract large portions of the graph+   -- * Extract large portions of the graph    graphMap,    nodeLabels, nodeSet, nodes, nodeEdges,    edgeLabels, edgeSet, edges, -   -- * queries+   -- * Queries    isEmpty,    lookupNode, lookupEdge,-   adjacentEdges,+   predecessors, successors,+   adjacentEdgeSet, adjacentEdges,    isLoop,    pathExists,    isConsistent, -   -- * manipulate labels+   -- * Manipulate labels    mapNode, mapNodeWithKey,    mapEdge, mapEdgeWithKey,    mapNodeWithInOut, InOut,    filterEdgeWithKey,    traverseNode, traverseEdge, traverse, -   -- * combine graphs+   -- * Combine graphs    checkedZipWith,    union, -   -- * manipulate indices+   -- * Manipulate indices    Reverse,    reverse,    reverseEdge,@@ -43,7 +44,7 @@    mapMaybeEdgeKeys,    mapEdgeKeys, -   -- * insertion and removal+   -- * Insertion and removal    deleteNode, deleteNodeSet, deleteEdge,    insertNode, insertEdge, insertEdgeSet,    ) where@@ -66,6 +67,7 @@ import Data.Map (Map) import Data.Monoid          (Monoid, mempty, mappend, All(All), getAll, Endo(Endo), appEndo)+import Data.Semigroup (Semigroup((<>)), ) import Data.Tuple.HT (mapFst, fst3, snd3, thd3, mapFst3, mapThd3)  import qualified Test.QuickCheck as QC@@ -374,6 +376,11 @@  instance    (Edge edge, Ord node) =>+      Semigroup (Graph edge node edgeLabel nodeLabel) where+   (<>) = union++instance+   (Edge edge, Ord node) =>       Monoid (Graph edge node edgeLabel nodeLabel) where    mempty = empty    mappend = union@@ -421,23 +428,33 @@ lookupNode :: (Ord n) => n -> Graph e n el nl -> Maybe nl lookupNode n (Graph g) = fmap snd3 $ Map.lookup n g -_pre, suc ::-   (Edge e, Ord n) =>-   Graph e n el nl -> n -> [n]-_pre g n =+{- |+Direct predecessors of a node,+i.e. nodes with an outgoing edge to the queried node.+-}+predecessors :: (Edge e, Ord n) => Graph e n el nl -> n -> [n]+predecessors g n =    map fromWrap . Map.keys . fst3 .-   Map.findWithDefault (error "pre: unknown node") n . graphMapWrap $ g-suc g n =+   Map.findWithDefault (error "predecessors: unknown node") n . graphMapWrap $ g++{- |+Direct successors of a node,+i.e. nodes with an incoming edge from the queried node.+-}+successors :: (Edge e, Ord n) => Graph e n el nl -> n -> [n]+successors g n =    map toWrap . Map.keys . thd3 .-   Map.findWithDefault (error "suc: unknown node") n . graphMapWrap $ g+   Map.findWithDefault (error "successors: unknown node") n . graphMapWrap $ g -adjacentEdges ::+{-# DEPRECATED adjacentEdges "Use adjacentEdgeSet instead." #-}+adjacentEdges, adjacentEdgeSet ::    (Edge e, Ord n) =>    Graph e n el nl -> n -> Set (e n)-adjacentEdges g n =+adjacentEdges = adjacentEdgeSet+adjacentEdgeSet g n =    (\(ins,_nl,outs) ->       unwrapSet $ Map.keysSet ins `Set.union` Map.keysSet outs) $-   Map.findWithDefault (error "adjacentEdges: unknown node") n $+   Map.findWithDefault (error "adjacentEdgeSet: unknown node") n $    graphMapWrap g  {-@@ -684,7 +701,7 @@ pathExists src dst =    let go gr a =           not (isEmpty gr) &&-          (a==dst || (any (go (deleteNode a gr)) $ suc gr a))+          (a==dst || (any (go (deleteNode a gr)) $ successors gr a))    in  flip go src  
test/Main.hs view
@@ -127,7 +127,7 @@    let isolated =          maybe False (const True) (Graph.lookupNode n gr)          &&-         Set.null (Graph.adjacentEdges gr n)+         Set.null (Graph.adjacentEdgeSet gr n)    in  isolated `implies`        Graph.insertNode n nl gr        ==