fgl-visualize (empty) → 0.1
raw patch · 4 files changed
+105/−0 lines, 4 filesdep +basedep +dotgendep +fglsetup-changed
Dependencies added: base, dotgen, fgl
Files
- Data/Graph/Inductive/Dot.hs +40/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- fgl-visualize.cabal +33/−0
+ Data/Graph/Inductive/Dot.hs view
@@ -0,0 +1,40 @@+{-| FGL To Dot is an automatic translation and labeling+ of FGL graphs (see the 'Graph' class) to graphviz+ Dot format that can be written out to a file and+ displayed.++@+ let dot = showDot (fglToDot graph)+ writeFile "file.dot" dot+ system("dot -Tpng -ofile.png file.dot")+@+-}++module Data.Graph.Inductive.Dot+ ( fglToDot, fglToDotString, fglToDotUnlabeled, fglToDotGeneric+ , showDot+ ) where++import Control.Monad+import Data.Graph.Inductive+import Text.Dot++-- |Generate a Dot graph using the show instances of the node and edge labels as displayed graph labels+fglToDot :: (Show a, Show b, Graph gr) => gr a b -> Dot ()+fglToDot gr = fglToDotGeneric gr show show id++-- |Generate a Dot graph using the Node and Edge strings as labels+fglToDotString :: Graph gr => gr String String -> Dot ()+fglToDotString gr = fglToDotGeneric gr id id id++-- |Generate a Dot graph without any edge or node labels+fglToDotUnlabeled :: Graph gr => gr a b -> Dot ()+fglToDotUnlabeled gr = fglToDotGeneric gr undefined undefined (const [])++-- |Generate a Dot graph using the provided functions to mutate the node labels, edge labels and list of attributes.+fglToDotGeneric :: Graph gr => gr a b -> (a -> String) -> (b -> String) -> ([(String,String)] -> [(String,String)]) -> Dot ()+fglToDotGeneric gr nodeConv edgeConv attrConv = do+ let es = labEdges gr -- :: [(Int, Int, b)]+ ns = labNodes gr -- :: [(Int, a)]+ mapM_ (\(n,p) -> userNode (userNodeId n) (attrConv [("label", nodeConv p)])) ns+ mapM_ (\(a,b,p) -> edge (userNodeId a) (userNodeId b) (attrConv [("label", edgeConv p)])) es
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2011, Thomas M. DuBuisson++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Thomas M. DuBuisson nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ fgl-visualize.cabal view
@@ -0,0 +1,33 @@+Name: fgl-visualize+Version: 0.1+Synopsis: Convert FGL graphs to dot (graphviz) files+Description: Convert FGL graphs to dot files for easy visualization+ using the 'dot' tool. Other visualizations might follow+ but there are no immediate plans (patches welcome).+License: BSD3+License-file: LICENSE+Author: Thomas M. DuBuisson+Maintainer: thomas.dubuisson@gmail.com++-- A copyright notice.+-- Copyright: ++Category: Graphs++Build-type: Simple++-- Extra files to be distributed with the package, such as examples or+-- a README.+-- Extra-source-files: ++-- Constraint on the version of Cabal needed to build this package.+Cabal-version: >=1.6+++Library+ Exposed-modules: Data.Graph.Inductive.Dot+ Build-depends: base >= 4 && < 4.6, fgl == 5.4.*, dotgen == 0.4.*+ + -- Other-modules: + -- Build-tools: +