graphite 0.7.0.0 → 0.8.0.0
raw patch · 4 files changed
+14/−17 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Graph.Types: adjacentVertices' :: (Graph g, Hashable v, Eq v) => g v e -> v -> [(v, e)]
+ Data.Graph.Types: adjacentVertices' :: (Graph g, Hashable v, Eq v) => g v e -> v -> [(v, v, e)]
- Data.Graph.Types: class Graph g where size = length . edgePairs edgePairs g = tripleToPair <$> edgeTriples g adjacentVertices g v = fst <$> adjacentVertices' g v reachableAdjacentVertices g v = fst <$> reachableAdjacentVertices' g v degrees g = vertexDegree g <$> vertices g maxDegree = maximum . degrees minDegree = minimum . degrees avgDegree g = fromIntegral (2 * size g) / fromIntegral (order g) density g = (2 * (e - n + 1)) / (n * (n - 3) + 2) where n = fromIntegral $ order g e = fromIntegral $ size 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
+ Data.Graph.Types: class Graph g where size = length . edgePairs edgePairs g = tripleToPair <$> edgeTriples g adjacentVertices g v = (\ (_, v', _) -> v') <$> adjacentVertices' g v reachableAdjacentVertices g v = (\ (_, v', _) -> v') <$> reachableAdjacentVertices' g v degrees g = vertexDegree g <$> vertices g maxDegree = maximum . degrees minDegree = minimum . degrees avgDegree g = fromIntegral (2 * size g) / fromIntegral (order g) density g = (2 * (e - n + 1)) / (n * (n - 3) + 2) where n = fromIntegral $ order g e = fromIntegral $ size 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
- Data.Graph.Types: reachableAdjacentVertices' :: (Graph g, Hashable v, Eq v) => g v e -> v -> [(v, e)]
+ Data.Graph.Types: reachableAdjacentVertices' :: (Graph g, Hashable v, Eq v) => g v e -> v -> [(v, v, e)]
Files
- graphite.cabal +1/−1
- src/Data/Graph/DGraph.hs +6/−7
- src/Data/Graph/Types.hs +6/−8
- src/Data/Graph/UGraph.hs +1/−1
graphite.cabal view
@@ -1,5 +1,5 @@ name: graphite-version: 0.7.0.0+version: 0.8.0.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
@@ -39,7 +39,7 @@ order (DGraph _ g) = HM.size g size (DGraph s _) = s vertices (DGraph _ g) = HM.keys g- edgePairs g = toPair <$> arcs g+ edgeTriples g = toTriple <$> arcs g containsVertex (DGraph _ g) = flip HM.member g@@ -52,17 +52,16 @@ (vertices g) adjacentVertices' g v = fmap- (\(fromV, toV, e) -> if fromV == v then (toV, e) else (fromV, e)) $+ (\(fromV, toV, e) -> if fromV == v then (fromV, toV, e) else (toV, fromV, e)) $ filter (\(fromV, toV, _) -> fromV == v || toV == v) (toTriple <$> toList g) reachableAdjacentVertices (DGraph _ g) v = HM.keys (getLinks v g) - reachableAdjacentVertices' g v = fmap (\(_, toV, e) -> (toV, e)) $- filter- (\(fromV, _, _) -> fromV == v)- (toTriple <$> toList g)+ reachableAdjacentVertices' g v = filter+ (\(fromV, _, _) -> fromV == v)+ (toTriple <$> toList g) -- | The total number of inbounding and outbounding 'Arc's of a vertex vertexDegree g v = vertexIndegree g v + vertexOutdegree g v@@ -74,7 +73,7 @@ where v1Links = getLinks v1 g - incidentEdgePairs g v = toPair <$> incidentArcs g v+ incidentEdgeTriples g v = toTriple <$> incidentArcs g v insertEdgeTriple (v1, v2, e) = insertArc (Arc v1 v2 e) removeEdgePair (v1, v2) graph@(DGraph s g)
src/Data/Graph/Types.hs view
@@ -44,11 +44,10 @@ -- | Retrieve the adjacent vertices of a vertex adjacentVertices :: (Hashable v, Eq v) => g v e -> v -> [v]- adjacentVertices g v = fst <$> adjacentVertices' g v+ adjacentVertices g v = (\(_, v', _) -> v') <$> adjacentVertices' g v - -- | Same as 'adjacentVertices' but pairs the vertex with the connecting- -- | edge's attribute- adjacentVertices' :: (Hashable v, Eq v) => g v e -> v -> [(v, e)]+ -- | Same as 'adjacentVertices' but gives back the connecting edges+ adjacentVertices' :: (Hashable v, Eq v) => g v e -> v -> [(v, v, e)] -- | Same as 'adjacentVertices' but gives back only those vertices for which -- | the connecting edge allows the vertex to be reached.@@ -57,11 +56,10 @@ -- | for the case of a directed graph, the directed arcs will constrain the -- | reachability of the adjacent vertices. reachableAdjacentVertices :: (Hashable v, Eq v) => g v e -> v -> [v]- reachableAdjacentVertices g v = fst <$> reachableAdjacentVertices' g v+ reachableAdjacentVertices g v = (\(_, v', _) -> v') <$> reachableAdjacentVertices' g v - -- | Same as 'reachableAdjacentVertices' but pairs the vertex with the- -- | connecting edge's attribute- reachableAdjacentVertices' :: (Hashable v, Eq v) => g v e -> v -> [(v, e)]+ -- | Same as 'reachableAdjacentVertices' but gives back the connecting edges+ reachableAdjacentVertices' :: (Hashable v, Eq v) => g v e -> v -> [(v, v, e)] -- | Total number of incident edges of a vertex vertexDegree :: (Hashable v, Eq v) => g v e -> v -> Int
src/Data/Graph/UGraph.hs view
@@ -50,7 +50,7 @@ containsVertex (UGraph _ g) = flip HM.member g areAdjacent (UGraph _ g) v1 v2 = HM.member v2 $ getLinks v1 g adjacentVertices (UGraph _ g) v = HM.keys $ getLinks v g- adjacentVertices' (UGraph _ g) v = HM.toList $ getLinks v g+ adjacentVertices' (UGraph _ g) v = fmap (\(toV, e) -> (v, toV, e)) $ HM.toList $ getLinks v g reachableAdjacentVertices = adjacentVertices reachableAdjacentVertices' = adjacentVertices' vertexDegree (UGraph _ g) v = length $ HM.keys $ getLinks v g