Maintainer | Ivan.Miljenovic@gmail.com |
---|
This module defines functions to call the various Graphviz commands. It is based upon code originally written for version 0.5 of Graphalyze: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Graphalyze-0.5
Whilst various output formats are supported (see GraphvizOutput
for a complete list), it is not yet possible to choose a desired
renderer and formatter. Being able to determine which renderers
and formatters are applicable for a specific GraphvizOutput
is
not easy (there is no listing of available renderers or formatters
on the Graphviz website), and for the most part the default ones do
the job well.
Please note that for GraphvizOutput
and GraphvizCanvas
, you
will see that they are instances of a GraphvizResult
class; this is
an internal class that should not be visible outside this module, but
Haddock is being too helpful for its own good.
- data GraphvizCommand
- dirCommand :: GraphvizCommand
- undirCommand :: GraphvizCommand
- commandFor :: DotRepr dg n => dg n -> GraphvizCommand
- data GraphvizOutput
- data GraphvizCanvas
- data RunResult
- maybeErr :: Either String a -> RunResult
- runGraphviz :: DotRepr dg n => dg n -> GraphvizOutput -> FilePath -> IO (Either String FilePath)
- runGraphvizCommand :: DotRepr dg n => GraphvizCommand -> dg n -> GraphvizOutput -> FilePath -> IO (Either String FilePath)
- addExtension :: (GraphvizOutput -> FilePath -> a) -> GraphvizOutput -> FilePath -> a
- runGraphvizCanvas :: DotRepr dg n => GraphvizCommand -> dg n -> GraphvizCanvas -> IO RunResult
- runGraphvizCanvas' :: DotRepr dg n => dg n -> GraphvizCanvas -> IO RunResult
- graphvizWithHandle :: DotRepr dg n => GraphvizCommand -> dg n -> GraphvizOutput -> (Handle -> IO a) -> IO (Either String a)
- hGetContents' :: Handle -> IO String
The different Graphviz tools available.
data GraphvizCommand Source
The available Graphviz commands. The following directions are
based upon those in the Graphviz man page (available online at
http://graphviz.org/pdf/dot.1.pdf, or if installed on your
system man graphviz
). Note that any command can be used on
both directed and undirected graphs.
dirCommand :: GraphvizCommandSource
The default command for directed graphs.
undirCommand :: GraphvizCommandSource
The default command for undirected graphs.
commandFor :: DotRepr dg n => dg n -> GraphvizCommandSource
The appropriate (default) Graphviz command for the given graph.
The possible outputs that Graphviz supports.
The list of output types supported by Graphviz is dependent upon
how it is built on your system. To determine which actual formats
are available on your system, run dot -T?
. Trying to use an
output type that is not supported by your installation of Graphviz
will result in an error.
The outputs defined here in GraphvizOutput
and GraphvizCanvas
are those from the default list of available outputs. For more
information, see:
http://graphviz.org/doc/info/output.html
data GraphvizOutput Source
The possible Graphviz output formats (that is, those that actually produce a file).
Bmp | Windows Bitmap Format. |
Canon | Pretty-printed Dot output with no layout performed. |
DotOutput | Reproduces the input along with layout information. |
XDot | As with |
Eps | Encapsulated PostScript. |
Fig | FIG graphics language. |
Gd | Internal GD library format. |
Gd2 | Compressed version of |
Gif | Graphics Interchange Format. |
Ico | Icon image file format. |
Imap | Server-side imagemap. |
Cmapx | Client-side imagemap. |
ImapNP | As for |
CmapxNP | As for |
Jpeg | The JPEG image format. |
Portable Document Format. | |
Plain | Simple text format. |
PlainExt | As for |
Png | Portable Network Graphics format. |
Ps | PostScript. |
Ps2 | PostScript for PDF. |
Svg | Scalable Vector Graphics format. |
SvgZ | Compressed SVG format. |
Tiff | Tagged Image File Format. |
Vml | Vector Markup Language; |
VmlZ | Compressed VML format; |
Vrml | Virtual Reality Modeling Language
format; requires nodes to have a
|
WBmp | Wireless BitMap format; monochrome format usually used for mobile computing devices. |
data GraphvizCanvas Source
Unlike GraphvizOutput
, these items do not produce an output
file; instead, they directly draw a canvas (i.e. a window) with
the resulting image.
Running Graphviz.
Represents the result of running a command.
maybeErr :: Either String a -> RunResultSource
Return the error if there is one, otherwise return Success.
runGraphviz :: DotRepr dg n => dg n -> GraphvizOutput -> FilePath -> IO (Either String FilePath)Source
Run the recommended Graphviz command on this graph, saving the result to the file provided (note: file extensions are not checked).
runGraphvizCommand :: DotRepr dg n => GraphvizCommand -> dg n -> GraphvizOutput -> FilePath -> IO (Either String FilePath)Source
Run the chosen Graphviz command on this graph, saving the result to the file provided (note: file extensions are not checked).
addExtension :: (GraphvizOutput -> FilePath -> a) -> GraphvizOutput -> FilePath -> aSource
Append the default extension for the provided GraphvizOutput
to
the provided FilePath
for the output file.
runGraphvizCanvas :: DotRepr dg n => GraphvizCommand -> dg n -> GraphvizCanvas -> IO RunResultSource
Run the chosen Graphviz command on this graph and render it using the given canvas type.
runGraphvizCanvas' :: DotRepr dg n => dg n -> GraphvizCanvas -> IO RunResultSource
Run the recommended Graphviz command on this graph and render it using the given canvas type.
:: DotRepr dg n | |
=> GraphvizCommand | Which command to run |
-> dg n | The |
-> GraphvizOutput | The |
-> (Handle -> IO a) | Extract the output |
-> IO (Either String a) | The error or the result. |
Run the chosen Graphviz command on this graph, but send the result to the given handle rather than to a file.
Note that the
function must fully consume
the input from the Handle
-> IO
aHandle
; hGetContents'
is a version of
hGetContents
that will ensure this happens.
If the command was unsuccessful, then
is returned.
Left
error
Helper utilities.
hGetContents' :: Handle -> IO StringSource
A version of hGetContents
that fully evaluates the contents of
the Handle
(that is, until EOF is reached). The Handle
is
not closed.