BaH.Graphviz: Constants Types Modinfo Source  

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 :

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
DescriptionA non-strict, directed graph.
InformationThis 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
DescriptionA strict, directed graph.
InformationThis graph type can have at most one edge between any pair of nodes.

Const AGRAPH:Int
DescriptionA non-strict, undirected graph.
InformationThis graph type allows an arbitrary number of edges between two nodes.

Const AGRAPHSTRICT:Int
DescriptionA strict, undirected graph.
InformationThis graph type can have at most one edge between any pair of nodes.

Const ATTR_FONTCOLOR:String
DescriptionColor used for text.
InformationSynonym for "fontcolor".

Const ATTR_LABEL:String
InformationSynonym for "label".

Const ATTR_NODE_FILLCOLOR:String
DescriptionNode background color.
InformationSynonym for "fillcolor".

Const ATTR_NODE_SHAPE:String
DescriptionDefine a node shape.
InformationSynonym for "shape".

Const ATTR_PENCOLOR:String
DescriptionBasic drawing color.
InformationSynonym for "color".

Const ATTR_STYLE:String
DescriptionStyle for node or edge.
InformationSynonym for "style".

Const GV_VIEW_ALL:Int

Const GV_VIEW_EDGE:Int

Const GV_VIEW_GRAPH:Int

Const GV_VIEW_NODE:Int

Const GV_VIEW_SUBGRAPH:Int

Types

Type TGVAttribute

Type TGVColor

Type TGVEdge Extends TGVGraphObject
DescriptionA graph edge. (GraphBuilder)
InformationAn edge connects two nodes.

Type TGVGraph Extends TGVGraphContainer
DescriptionThe root graph. (GraphBuilder)
Function Create:TGVGraph(graphType:Int = AGDIGRAPH)
DescriptionCreates a new TGVGraph of the specified graphType.
InformationgraphType should be one of AGRAPH, AGRAPHSTRICT, AGDIGRAPH or AGDIGRAPHSTRICT.
The deafult is AGDIGRAPH.

Type TGVGraphContainer Extends TGVGraphObject
DescriptionA container of subgraphs, nodes and edges. (GraphBuilder)
InformationBoth the root graph ( TGVGraph ) and subgraphs ( TGVSubGraph ) are valid containers.
Method addEdge:TGVEdge(nodeFrom:TGVNode, nodeTo:TGVNode)
ReturnsThe new TGVEdge object.
DescriptionAdds a TGVEdge to this container, creating a connection between nodeFrom and nodeTo.
Method addNode:TGVNode(name:String)
ReturnsThe new TGVNode object.
DescriptionAdds a TGVNode to this container.
InformationThe name should be unique for the graph!!
Method addSubGraph:TGVSubGraph(name:String)
ReturnsThe new TGVSubGraph object.
DescriptionAdds a TGVSubGraph to this container.
InformationThe name should be unique for the graph!!

Type TGVGraphObject
DescriptionBase type for building in-memory graph structures. (GraphBuilder)
Method setAttr(name:String, value:String)
DescriptionSets an attribute of the given name and value pair.
InformationSome useful attribute names include ATTR_LABEL, ATTR_NODE_SHAPE, ATTR_NODE_FILLCOLOR, ATTR_PENCOLOR, ATTR_NODE_FONTCOLOR and ATTR_STYLE.

Type TGVGraphviz
DescriptionA Graphviz renderer.
Method buildGraph(gvGraph:TGVGraph)
DescriptionBuilds a graph from the supplied TGVGraph structure.
Method drawTooltip(x:Int, y:Int, style:TGVStyle = Null)
DescriptionDraws the currently selected graph object at the specified location.
Method fit(width:Int, height:Int, expand:Int = False)
DescriptionResizes the graph to fit within the specified size.
InformationWill only "shrink to fit" unless expand is True, wherein the graph will expanded as necessary.
Method layout(layoutType:String)
DescriptionProcesses the graph using the specified layout engine.
InformationValid values for layoutType are :
Method loadGraphText(text:String)
DescriptionLoads the graph contained within text.
Method MouseDown(x:Int, y:Int, button:Int)
DescriptionInform the engine of a mouse button down.
Method mouseMove(x:Int, y:Int)
DescriptionInform the engine that the mouse was moved.
Method mouseScroll(x:Int, y:Int, direction:Int)
DescriptionProvide mouse scroll (zoom) information to the engine.
InformationA negative direction implies zooming in. A positive direction, zooming out.
Method mouseUp(x:Int, y:Int, button:Int)
DescriptionInform the engine of a mouse button release.
Method refresh(width:Int = 0, height:Int = 0)
DescriptionRefresh the graph, using the optional new display width and height.
Method selectedObject:TGViewObject(selection:Int = GV_VIEW_ALL)
DescriptionReturns the currently selected graph object, or Null.
Informationselection determines what graph object kinds to return. The default is all kinds, but can be one or more of GV_VIEW_GRAPH, GV_VIEW_SUBGRAPH, GV_VIEW_NODE or GV_VIEW_EDGE, or GV_VIEW_ALL.
Valid graph objects are TGViewGraph, TGViewSubGraph, TGViewNode and TGViewEdge.
Method toolTip:String()
DescriptionReturns the tooltip text of the currently selected graph object.
Function Create:TGVGraphviz(width:Int, height:Int)
DescriptionCreates a new TGVGraphviz of the specified dimensions.
Informationwidth 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 TGViewObject

Type TGViewSubGraph Extends TGViewGraph

Type TGVNode Extends TGVGraphObject
DescriptionA graph node. (GraphBuilder)

Type TGVStyle

Type TGVSubGraph Extends TGVGraphContainer
DescriptionA subgraph. (GraphBuilder)
InformationSubgraphs play three roles in Graphviz.
  • First, a subgraph can be used to represent graph structure, indicating that certain nodes and edges should be grouped together. This is the usual role for subgraphs and typically specifies semantic information about the graph components.
  • In the second role, a subgraph can provide a context for setting attributes. In Graphviz, these are often attributes used by the layout and rendering functions. For example, the application could specify that blue is the default color for nodes. Then, every node within the subgraph will have color blue.
    In the context of graph drawing, a more interesting example is:
    subgraph {
    rank = same; A; B; C;
    }
    This (anonymous) subgraph specifies that the nodes A, B and C should all be placed on the same rank if drawn using dot.
  • The third role for subgraphs combines the previous two. If the name of the subgraph begins with "cluster", Graphviz identifies the subgraph as a special cluster subgraph. The software will do the layout of the graph so that the nodes belonging to the cluster are drawn together, with the entire drawing of the cluster contained within a bounding rectangle.

Module Information

Version0.95
LicenseCommon Public License
CopyrightAT&T Research
CopyrightWrapper - 2007 Bruce A Henderson
ModserverBRL
History0.95 Initial Release
HistoryIncludes Graphviz 2.12 source.
CC_OPTS-DHAVE_CONFIG_H
CC_OPTS-fexceptions
CC_OPTS-DMSWIN32