fgl-visualize-0.1.0.1/0000755000000000000000000000000012145247367012631 5ustar0000000000000000fgl-visualize-0.1.0.1/fgl-visualize.cabal0000644000000000000000000000174312145247367016403 0ustar0000000000000000Name: fgl-visualize Version: 0.1.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 && < 5, fgl >= 5.4, dotgen >= 0.4 -- Other-modules: -- Build-tools: fgl-visualize-0.1.0.1/Setup.hs0000644000000000000000000000005612145247367014266 0ustar0000000000000000import Distribution.Simple main = defaultMain fgl-visualize-0.1.0.1/LICENSE0000644000000000000000000000277712145247367013653 0ustar0000000000000000Copyright (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. fgl-visualize-0.1.0.1/Data/0000755000000000000000000000000012145247367013502 5ustar0000000000000000fgl-visualize-0.1.0.1/Data/Graph/0000755000000000000000000000000012145247367014543 5ustar0000000000000000fgl-visualize-0.1.0.1/Data/Graph/Inductive/0000755000000000000000000000000012145247367016475 5ustar0000000000000000fgl-visualize-0.1.0.1/Data/Graph/Inductive/Dot.hs0000644000000000000000000000311112145247367017553 0ustar0000000000000000{-| 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