packages feed

algebraic-graphs-io 0.1.2.0 → 0.1.3.0

raw patch · 4 files changed

+36/−2 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Algebra.Graph.IO.Datasets: karateClub :: IO (Graph Int)
+ Algebra.Graph.IO.Datasets: lesMiserables :: IO (Graph Int)

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+* 0.1.2++  Add "Les Miserables" and "Karate Club" datasets++ * 0.1.0.0 (20/12/2012)    Release candidate
README.md view
@@ -1,6 +1,6 @@ # algebraic-graphs-io -This package aims to collect some I/Outilities for `algebraic-graphs`, e.g. parsers and serializers for common graph data interchange formats.+This package aims to collect some I/O utilities for `algebraic-graphs`, e.g. parsers and serializers for common graph data interchange formats.  Currently it provides a parser for the GML format, which is used by a few common graph software packages (NetworkX, Gephi, graphviz, and others). 
algebraic-graphs-io.cabal view
@@ -1,5 +1,5 @@ name:                algebraic-graphs-io-version:             0.1.2.0+version:             0.1.3.0 synopsis:            I/O utilities for algebraic-graphs description:         I/O utilities for algebraic-graphs. Currently, parsers for the GML format. homepage:            https://github.com/ocramz/algebraic-graphs-io@@ -25,6 +25,7 @@   hs-source-dirs:      src   exposed-modules:     Algebra.Graph.IO.GML                        Algebra.Graph.IO.Internal.Megaparsec+                       Algebra.Graph.IO.Datasets   build-depends:       base >= 4.7 && < 5                      , algebraic-graphs                      , containers
+ src/Algebra/Graph/IO/Datasets.hs view
@@ -0,0 +1,28 @@+{-# options_ghc -Wno-unused-imports -Wno-type-defaults #-}+module Algebra.Graph.IO.Datasets where++import Algebra.Graph (Graph)+import Algebra.Graph.IO.GML (GMLGraph, gmlGraph, gmlGraphP)+import Algebra.Graph.IO.Internal.Megaparsec (Parser, anyString)++import Text.Megaparsec (parse)+import Text.Megaparsec.Error (errorBundlePretty)+import Text.Megaparsec.Char.Lexer (decimal)++import Data.Text.IO (readFile)++import Prelude hiding (readFile)++lesMiserables :: IO (Graph Int)+lesMiserables = do+  t <- readFile "assets/lesmiserables.gml"+  case parse (gmlGraphP decimal decimal) "" t of+    Right gg -> pure $ gmlGraph gg+    Left e -> error $ errorBundlePretty e++karateClub :: IO (Graph Int)+karateClub = do+  t <- readFile "assets/karate.gml"+  case parse (gmlGraphP decimal anyString) "" t of+    Right gg -> pure $ gmlGraph gg+    Left e -> error $ errorBundlePretty e