Graphviz Library
Graphviz is an open source graph visualization library, which is a way of representing structural information as diagrams of abstract graphs and networks.
The Graphviz BlitzMax module allows you to utilise the powers of the layout engine to provide interactive graphs in your applications. These graphs can be generated through the provision of "dot" files, or you can create a graph on the fly using a simple Graph-Node-Edge object heirarchy in memory.
Requirements
The Graphviz module requires the BaH.Expat module, to provide enhanced node text layout.
Using the API - Basics
Using the API - In-memory graphing
Examples
Here are some examples that show the kind of things that can be done with Graphviz.
The implemented mouse actions in the examples are generally :
- Left button click - select a node/edge/graph.
- Right button click/drag - pan graph.
- Mouse scroll - zoom in / out at mouse position.
Learning Graphviz
This section is aimed at providing everything you need to know about creating your own graphs using the"dot" language, as well as help you understand all the attributes available to graphs, nodes and edges.
There are several types of layout you can specify when creating your graph or when generating a new TGVGraph :
- dot
- Makes "hierarchical" or layered drawings of directed graphs. The layout algorithm aims edges in the same direction (top to bottom, or left to right) and then attempts to avoid edge crossings and reduce edge length.
- neato and fdp
- Makes "spring model" layouts. neato uses the Kamada-Kawai algorithm, which is equivalent to statistical multi-dimensional scaling. fdp implements the Fruchterman-Reingold heuristic including a multigrid solver that handles larger graphs and clustered undirected graphs.
- twopi
- Uses a radial layout, after Graham Wills 97. The nodes are placed on concentric circles depending their distance from a given root node.
- circo
- Uses circular layout, after Six and Tollis 99, Kauffman and Wiese 02. This is suitable for certain diagrams of multiple cyclic structures such as certain telecommunications networks.
Note : The above documentation is taken from the Graphviz online documentation, and has been changed where appropriate for describing use in BlitzMax.
Constants
Const AGDIGRAPH:Int |
Description | A non-strict, directed graph. |
Information | This graph type allows an arbitrary number of edges between two nodes.
In a directed graph, the pair of nodes is ordered, so the graph can have edges from node A to node B
as well as edges from B to A. |
Const AGDIGRAPHSTRICT:Int |
Description | A strict, directed graph. |
Information | This graph type can have at most one edge between any pair of nodes. |
Const AGRAPH:Int |
Description | A non-strict, undirected graph. |
Information | This graph type allows an arbitrary number of edges between two nodes. |
Const AGRAPHSTRICT:Int |
Description | A strict, undirected graph. |
Information | This graph type can have at most one edge between any pair of nodes. |
Const ATTR_FONTCOLOR:String |
Description | Color used for text. |
Information | Synonym for "fontcolor". |
Const ATTR_LABEL:String |
Information | Synonym for "label". |
Const ATTR_NODE_FILLCOLOR:String |
Description | Node background color. |
Information | Synonym for "fillcolor". |
Const ATTR_NODE_SHAPE:String |
Description | Define a node shape. |
Information | Synonym for "shape". |
Const ATTR_PENCOLOR:String |
Description | Basic drawing color. |
Information | Synonym for "color". |
Const ATTR_STYLE:String |
Description | Style for node or edge. |
Information | Synonym for "style". |
Const GV_VIEW_SUBGRAPH:Int |
Types
Type TGVEdge Extends TGVGraphObject |
Description | A graph edge. (GraphBuilder) |
Information | An edge connects two nodes. |
Type TGVGraph Extends TGVGraphContainer |
Description | The root graph. (GraphBuilder) |
Type TGVGraphContainer Extends TGVGraphObject |
Description | A container of subgraphs, nodes and edges. (GraphBuilder) |
Information | Both the root graph ( TGVGraph ) and subgraphs ( TGVSubGraph ) are valid containers. |
Method addEdge:TGVEdge(nodeFrom:TGVNode, nodeTo:TGVNode) |
Returns | The new TGVEdge object. |
Description | Adds a TGVEdge to this container, creating a connection between nodeFrom and nodeTo. |
Method addNode:TGVNode(name:String) |
Returns | The new TGVNode object. |
Description | Adds a TGVNode to this container. |
Information | The name should be unique for the graph!! |
Method addSubGraph:TGVSubGraph(name:String) |
Returns | The new TGVSubGraph object. |
Description | Adds a TGVSubGraph to this container. |
Information | The name should be unique for the graph!! |
Type TGVGraphObject |
Description | Base type for building in-memory graph structures. (GraphBuilder) |
Type TGVGraphviz |
Description | A Graphviz renderer. |
Method buildGraph(gvGraph:TGVGraph) |
Description | Builds a graph from the supplied TGVGraph structure. |
Method fit(width:Int, height:Int, expand:Int = False) |
Description | Resizes the graph to fit within the specified size. |
Information | Will only "shrink to fit" unless expand is True, wherein the graph will expanded as necessary. |
Method layout(layoutType:String) |
Description | Processes the graph using the specified layout engine. |
Information | Valid values for layoutType are :
|
Method loadGraphText(text:String) |
Description | Loads the graph contained within text. |
Method MouseDown(x:Int, y:Int, button:Int) |
Description | Inform the engine of a mouse button down. |
Method mouseMove(x:Int, y:Int) |
Description | Inform the engine that the mouse was moved. |
Method mouseUp(x:Int, y:Int, button:Int) |
Description | Inform the engine of a mouse button release. |
Method refresh(width:Int = 0, height:Int = 0) |
Description | Refresh the graph, using the optional new display width and height. |
Function Create:TGVGraphviz(width:Int, height:Int) |
Description | Creates a new TGVGraphviz of the specified dimensions. |
Information | width and height are required for correct drawing of the graph at various magnifications. |
Type TGViewEdge Extends TGViewObject |
Type TGViewGraph Extends TGViewObject |
Type TGViewNode Extends TGViewObject |
Type TGViewSubGraph Extends TGViewGraph |
Type TGVNode Extends TGVGraphObject |
Description | A graph node. (GraphBuilder) |
Type TGVSubGraph Extends TGVGraphContainer |
Description | A subgraph. (GraphBuilder) |
Information | Subgraphs play three roles in Graphviz.
|
Module Information
Version | 0.95 |
License | Common Public License |
Copyright | AT&T Research |
Copyright | Wrapper - 2007 Bruce A Henderson |
Modserver | BRL |
History | 0.95 Initial Release |
History | Includes Graphviz 2.12 source. |
CC_OPTS | -DHAVE_CONFIG_H |
CC_OPTS | -fexceptions |
CC_OPTS | -DMSWIN32 |