Search

11/26/2009

graphviz

Graphviz - Graph Visualization Software, documentation
canviz: graphviz on a canvas
Graphviz FAQ
http://graphviz.org/Documentation/dotguide.pdf

dot draws a graph in four main phases. The layout procedure used by dot relies on the graph being acyclic.
(1) Thus, the first step is to break any cycles which occur in the input graph by reversing the internal direction of certain cyclic edges.
(2) The next step assigns nodes to discrete ranks or levels. In a top-to-bottom drawing, ranks determine Y coordinates. Edges that span more than one rank are broken into chains of “virtual” nodes and unit-length edges.
(3) The third step orders nodes within ranks to avoid crossings.
(4) The fourth step sets X coordinates of nodes to keep edges short, and the final step routes edge splines.

* The dot language descries three kinds of objects: graphs, nodes, and edges. With in a main graph, a subgraph defines a subset of nodes and edges.
* It is often useful to adjust the representation or placement of nodes and edges in the layout. This is done by setting attributes of nodes, edgets or subgraphs in the input file. Attributes are name-value pairs of character strings.


2. Drawing Attributes
* Nodes are drawn, by default, width shape=ellipse, width=.75, height=.5 and labeled by the node name. Other common shapes include box, circle, recode and plaintext.
* The node shape plaintext draws a node without any outline, an important convention in some kinds of diagrams.
* In case where the graph structure is of main concern, and especially when the graph is moderately large, the point shape reduces nodes to display minimal content. When drawn, a node's actual size is the greater of the requested size and the area needed for its text label, unless fixedsize=true, in which case the width and height values are enforced.
* The shape polygon exposes all the polygonal parameters, and is useful for creating many shapes that are not predefined. In addition to the parameters regular, peripheries and orientation, polygons are parameterized by number of sides sides, skew and distortioin.
* Graphs and cluster subgraphs may also have labels. graph labels appear, by default, centered below the graph. Setting labelloc=t centers the label above the graph. Cluster labels appear within the enclosing rectangle, in the upper left corner. The value labelloc=b moves the label to the bottom of the rectangle. The setting labeljust=rmoves the label to the right.
* Sometimes avoiding collisions among edge labels and edges forces the drawing to be bigger than desired. If labelfloat=true, dot does not try to prevent such overlaps, allowing a more compact drawing.
* An edge can also specify additional labels, using headlabel and taillabel, which are be placed near the ends of the edge. The characteristic of these labels are specified using the attributes labelfontname, labelfontsize and labelfontcolor.
2.5 Node and Edge Placement
* The rank of a subgraph may be set to same, min, source, max or sink.
* A value same causes all the nodes in the subgraph to occur on teh same rank. If set to min, all the nodes in the subgraph are guaranteed to be on a rank at least as small as any other node in the layout.
* This can be made strict by setting rank=source, which forces the nodes in the subgraph to be on some rank strctly smaller than the rank of any other nodes (except those also specified by min or source subgraphs).

diagraph G {
size = "4, 4";
main [shape=box]; /* This is a comment*/
main -> parse [weight=8]
parse -> execute;
main -> init [style=dotted];
main -> clean up;
execute -> {make_string; printf} /* makes edges from execute to make_string and printf*/
init -> make_string;
edge [color=red];
main -> printf [style="bod, label="100 times"]
make_string [label="make a\nstring"];
node [shape=box, style=filed, color=".7 .3 1.0"];
execute -> compare;
}


graphviz

3.2 Clusters
* A cluster is a subgraph placed in its own distinct rectangle of the layout. A subgraph is recognized as a cluseter when its name has the prefix cluster.
* Labels, font characteristics and the labelloc attribute can be set as they would be for the top-level graph, though cluster labels appear above the graph by defaut.
* Clusters are drawn by a recursive technique that computes a rank assignment and internal ordering of nodes within clusters.
* If the top-level graph has the compound attribute set to true, dot will allow edges connecting nodes and clusters. This is accomplished by an edge defining an lhead or ltail attribute. The value of these attributes must be the name of a cluster containing the head or tail node, respectively.
How can I create edges between cluster boxes?
This only works in Graphviz version 1.7 and higher. To make edges between clusters, first set the graph attribute compound=true. Then, you can specify a cluster by name as a logical head or tail to an edge. This will cause the edge joining the two nodes to be clipped to the exterior of the box around the given cluster.
digraph G {
compound=true;
nodesep=1.0;
subgraph cluster_A {
a -> b;
a -> c;
}
subgraph cluster_B {
d -> e;
f -> e;
}
a -> e [ ltail=cluster_A,
lhead=cluster_B ];
}

output


node attributes
graph attributes
edge attributes
ref:
lf387, Graphics: Automate the creation of graphs with Graphviz

沒有留言: