-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from thisiswhereitype/master
pangraph-0.2.0
- Loading branch information
Showing
19 changed files
with
377 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Changelog | ||
|
||
pangraph-0.2.0 | ||
* Addition of conversion and revert for FGL. | ||
* Addition of Parser, Serializer and AST for GML. | ||
* Change `Edge` types to now only construct with a `VertexID` type. | ||
* Change `edgeEndpoints` to return VertexID. | ||
|
||
pangraph-0.1.2 141360fbc2b6ca232ce91a9b14aa9a626082ba92 08/06/2018 | ||
Note: First Hackage release which follows correct cabal versioning increments. | ||
* Addition of Containers (convert). | ||
* Bump to Stack LTS. | ||
* Update to Algebraic Graphs to build with more versions. | ||
|
||
pangraph-0.1.1.5 49bc8a38842256b7fb7c285725dcfb6dfb03cfcb 03/02/2018 | ||
Note: First hackage release, prior to this on the repo there are many issues with commits. | ||
Note: Commit date earlier. | ||
Note: This list is of all features up to this point. | ||
* Parser and serlizer for subset of Graphml. | ||
* Implementation of Algebraic Graphs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
{-| | ||
Module : Pangraph.Containers | ||
Description : Convert `Pangraph` into a CGraph.Graph | ||
-} | ||
module Pangraph.Containers | ||
( convert | ||
) where | ||
|
||
import Pangraph | ||
import qualified Data.Graph as CGraph | ||
|
||
import Data.Maybe (fromMaybe) | ||
import Data.List (groupBy, sort) | ||
import Control.Arrow ((***)) | ||
import Data.Maybe (fromMaybe) | ||
|
||
import Data.Map.Strict (Map) | ||
import qualified Data.Map.Strict as Map | ||
import qualified Data.Graph as CGraph | ||
import Data.Map.Strict (Map) | ||
import qualified Data.Map.Strict as Map | ||
|
||
-- | Transforms a 'Pangraph' in a 'CGraph.Graph'. | ||
-- | Transforms a 'Pangraph' into a 'CGraph.Graph'. | ||
convert :: Pangraph -> (CGraph.Graph, CGraph.Vertex -> (Vertex, VertexID, [VertexID]), VertexID -> Maybe CGraph.Vertex) | ||
convert p = CGraph.graphFromEdges getVertices | ||
where | ||
-- A helper function for getting the IDs of endpoints. | ||
edgeEndpointIDs :: Edge -> (VertexID, VertexID) | ||
edgeEndpointIDs e = (vertexID *** vertexID) $ edgeEndpoints e | ||
|
||
convert p = let | ||
-- Create an Edge Map using VertexID grouping edge sources together. | ||
edgeMap :: Map VertexID [VertexID] | ||
edgeMap = (Map.fromList . groupIDs) $ map edgeEndpointIDs $ edgeList p | ||
edgeMap = (Map.fromList . groupIDs . map edgeEndpoints . edgeList) p | ||
|
||
-- Lookup the edges for this vertex. Returning empty list on Nothing. | ||
-- Lookup the edges for this vertex. Returning empty list on Nothing. Which means there are no outgoing arcs. | ||
vertexConnections :: Vertex -> [VertexID] | ||
vertexConnections v = fromMaybe [] (Map.lookup (vertexID v) edgeMap) | ||
|
||
-- Convert Pangraph Vertex into a form ready to collect Edges from the Pangraph | ||
getVertices :: [(Vertex, VertexID, [VertexID])] | ||
getVertices = map (\v ->(v, vertexID v, vertexConnections v)) $ vertexList p | ||
in CGraph.graphFromEdges getVertices | ||
|
||
groupIDs :: [(VertexID, VertexID)] -> [(VertexID, [VertexID])] | ||
groupIDs vs = map (\ts -> (fst $ head ts, map snd ts)) groupedEdges | ||
where | ||
groupIDs endPoints =let | ||
groupedEdges :: [[(VertexID, VertexID)]] | ||
groupedEdges = groupBy (\a b -> fst a == fst b) $ sort vs | ||
groupedEdges = groupBy (\a b -> fst a == fst b) (sort endPoints) | ||
in map (\ts -> (fst $ head ts, map snd ts)) groupedEdges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.