packages feed

graphite 0.9.5.1 → 0.9.6.0

raw patch · 5 files changed

+14/−20 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Graph.Generation: rndGraph :: forall g v e. (Graph g, Hashable v, Eq v, Enum v, Random e) => (v, v) -> (e, e) -> Float -> IO (g v e)
+ Data.Graph.Generation: rndGraph :: forall g v e. (Graph g, Hashable v, Eq v, Random e) => (e, e) -> Float -> [v] -> IO (g v e)
- Data.Graph.Generation: rndGraph' :: forall g v. (Graph g, Hashable v, Eq v, Enum v) => (v, v) -> Float -> IO (g v ())
+ Data.Graph.Generation: rndGraph' :: forall g v. (Graph g, Hashable v, Eq v) => Float -> [v] -> IO (g v ())
- Data.Graph.Types: class Graph g where size = length . edgePairs density g = (2 * (e - n + 1)) / (n * (n - 3) + 2) where n = fromIntegral $ order g e = fromIntegral $ size g edgePairs g = tripleToPair <$> edgeTriples g adjacentVertices g v = tripleDestVertex <$> adjacentVertices' g v reachableAdjacentVertices g v = tripleDestVertex <$> reachableAdjacentVertices' g v degrees g = vertexDegree g <$> vertices g maxDegree = maximum . degrees minDegree = minimum . degrees avgDegree g = fromIntegral (2 * size g) / fromIntegral (order g) insertVertices vs g = foldl' (flip insertVertex) g vs incidentEdgePairs g v = tripleToPair <$> incidentEdgeTriples g v insertEdgeTriples es g = foldl' (flip insertEdgeTriple) g es insertEdgePair (v1, v2) = insertEdgeTriple (v1, v2, ()) insertEdgePairs es g = foldl' (flip insertEdgePair) g es removeVertices vs g = foldl' (flip removeVertex) g vs removeEdgePairs es g = foldl' (flip removeEdgePair) g es removeEdgePairAndVertices (v1, v2) g = removeVertex v2 $ removeVertex v1 $ removeEdgePair (v1, v2) g isolatedVertices g = filter (\ v -> vertexDegree g v == 0) $ vertices g fromList links = go links empty where go [] g = g go ((v, es) : rest) g = go rest $ foldr (\ (v', e) g' -> insertEdgeTriple (v, v', e) g') (insertVertex v g) es
+ Data.Graph.Types: class Graph g where size = length . edgePairs density g = (2 * (e - n + 1)) / (n * (n - 3) + 2) where n = fromIntegral $ order g e = fromIntegral $ size g edgePairs g = tripleToPair <$> edgeTriples g areAdjacent g v1 v2 = containsEdgePair g (v1, v2) || containsEdgePair g (v2, v1) adjacentVertices g v = tripleDestVertex <$> adjacentVertices' g v reachableAdjacentVertices g v = tripleDestVertex <$> reachableAdjacentVertices' g v degrees g = vertexDegree g <$> vertices g maxDegree = maximum . degrees minDegree = minimum . degrees avgDegree g = fromIntegral (2 * size g) / fromIntegral (order g) insertVertices vs g = foldl' (flip insertVertex) g vs incidentEdgePairs g v = tripleToPair <$> incidentEdgeTriples g v insertEdgeTriples es g = foldl' (flip insertEdgeTriple) g es insertEdgePair (v1, v2) = insertEdgeTriple (v1, v2, ()) insertEdgePairs es g = foldl' (flip insertEdgePair) g es removeVertices vs g = foldl' (flip removeVertex) g vs removeEdgePairs es g = foldl' (flip removeEdgePair) g es removeEdgePairAndVertices (v1, v2) g = removeVertex v2 $ removeVertex v1 $ removeEdgePair (v1, v2) g isolatedVertices g = filter (\ v -> vertexDegree g v == 0) $ vertices g fromList links = go links empty where go [] g = g go ((v, es) : rest) g = go rest $ foldr (\ (v', e) g' -> insertEdgeTriple (v, v', e) g') (insertVertex v g) es

Files

graphite.cabal view
@@ -1,5 +1,5 @@ name:                graphite-version:             0.9.5.1+version:             0.9.6.0 synopsis:            Graphs and networks library description:         Represent, analyze and visualize graphs homepage:            https://github.com/alx741/graphite#readme
src/Data/Graph/DGraph.hs view
@@ -125,10 +125,7 @@      insertVertex v (DGraph s g) = DGraph s $ hashMapInsert v HM.empty g -    containsEdgePair graph@(DGraph _ g) (v1, v2) =-        containsVertex graph v1 && containsVertex graph v2 && v2 `HM.member` v1Links-        where v1Links = getLinks v1 g-+    containsEdgePair (DGraph _ g) (v1, v2) = v2 `HM.member` (getLinks v1 g)      incidentEdgeTriples g v = toTriple <$> incidentArcs g v     insertEdgeTriple (v1, v2, e) = insertArc (Arc v1 v2 e)
src/Data/Graph/Generation.hs view
@@ -27,7 +27,7 @@  -- | Generate a random Erdős–Rényi G(n, p) model graph erdosRenyi :: Graph g => Int -> Float -> IO (g Int ())-erdosRenyi n = rndGraph' (1, n)+erdosRenyi n p = rndGraph' p [1..n]  -- | 'erdosRenyi' convinience 'UGraph' generation function erdosRenyiU :: Int -> Float -> IO (UGraph Int ())@@ -38,15 +38,15 @@ erdosRenyiD = erdosRenyi  --- | Generate a random graph with vertices in /v/ across range of given bounds,+-- | Generate a random graph for all the vertices of type /v/ in the list, -- random edge attributes in /e/ within given bounds, and some existing -- probability for each possible edge as per the Erdős–Rényi model-rndGraph :: forall g v e . (Graph g, Hashable v, Eq v, Enum v, Random e)- => (v, v)- -> (e, e)+rndGraph :: forall g v e . (Graph g, Hashable v, Eq v, Random e)+ => (e, e)  -> Float+ -> [v]  -> IO (g v e)-rndGraph (n1, n2) edgeBounds p = go [n1..n2] (probability p) empty+rndGraph edgeBounds p verts = go verts (probability p) empty     where         go :: [v] -> Float -> g v e -> IO (g v e)         go [] _ g = return g@@ -60,11 +60,11 @@   -- | Same as 'rndGraph' but uses attributeless edges-rndGraph' :: forall g v . (Graph g, Hashable v, Eq v, Enum v)- => (v, v)- -> Float+rndGraph' :: forall g v . (Graph g, Hashable v, Eq v)+ => Float+ -> [v]  -> IO (g v ())-rndGraph' (n1, n2) p = go [n1..n2] (probability p) empty+rndGraph' p verts = go verts (probability p) empty     where         go :: [v] -> Float -> g v () -> IO (g v ())         go [] _ g = return g
src/Data/Graph/Types.hs view
@@ -40,8 +40,6 @@ -- class should be used for algorithms that are graph-directionality agnostic, -- otherwise use the more specific ones in 'UGraph' and 'DGraph' class Graph g where-    -- * Properties-     -- | The Empty (order-zero) graph with no vertices and no edges     empty :: (Hashable v) => g v e @@ -84,6 +82,7 @@      -- | Tell if two vertices are adjacent     areAdjacent :: (Hashable v, Eq v) => g v e -> v -> v -> Bool+    areAdjacent g v1 v2 = containsEdgePair g (v1, v2) || containsEdgePair g (v2, v1)      -- | Retrieve the adjacent vertices of a vertex     adjacentVertices :: (Hashable v, Eq v) => g v e -> v -> [v]
src/Data/Graph/UGraph.hs view
@@ -102,9 +102,7 @@     vertexDegree (UGraph _ g) v = length $ HM.keys $ getLinks v g     insertVertex v (UGraph s g) = UGraph s $ hashMapInsert v HM.empty g -    containsEdgePair graph@(UGraph _ g) (v1, v2) =-        containsVertex graph v1 && containsVertex graph v2 && v2 `HM.member` v1Links-        where v1Links = getLinks v1 g+    containsEdgePair (UGraph _ g) (v1, v2) = v2 `HM.member` (getLinks v1 g)      incidentEdgeTriples g v = toTriple <$> incidentEdges g v     insertEdgeTriple (v1, v2, e) = insertEdge (Edge v1 v2 e)