I have a graph (organigram) how this:
digraph G {
nodesep=0.3;
ranksep=0.2;
margin=0.1;
node [shape=rectangle];
edge [arrowsize=0.8];
1 -> 2;
1 -> 3;
1 -> 4;
1 -> 5;
1 -> 6;
1 -> 7;
1 -> 8;
1 -> 9;
1 -> 10;
}
I have organigrams with 70 people and it's impossible to print in A4. How would I put nodes in 2 or 3 lines?
In the matroid theory of graphs the rank of an undirected graph is defined as the number n − c, where c is the number of connected components of the graph. Equivalently, the rank of a graph is the rank of the oriented incidence matrix associated with the graph.
neato is a reasonable default tool to use for undirected graphs that aren't too large (about 100 nodes), when you don't know anything else about the graph. neato attempts to minimize a global energy function, which is equivalent to statistical multi-dimensional scaling.
Create a graph object, assemble the graph by adding nodes and edges, and retrieve its DOT source code string. Save the source code to a file and render it with the Graphviz installation of your system. Use the view option/method to directly inspect the resulting (PDF, PNG, SVG, etc.) file with its default application.
Here are two possibilities (see also this question):
unflatten
utilityGraphviz provides a tool called unflatten
. If you pre-process your graph using this command line:
unflatten -l 3 wide.gv | dot -Tpng -o wide.png
the output image will be similar to the below picture. This is slightly less wide, and you may play with the -l
option.
You may use the standard techniques to make a automatically layed out graphs look more like you want it to:
rank=same
to group nodes in subgraphs and to define which nodes should be on the same lineconstraint=false
for some edges to influence the layoutgroup
attributes of nodes to encourage straight edges. The output graph will not necessarily be prettier...
Here's an example, you can probably do better. Also, this may not be very practical if the graph is generated dynamically.
digraph G {
nodesep=0.3;
ranksep=0.2;
margin=0.1;
node [shape=rectangle];
edge [arrowsize=0.8];
edge[style=invis];
node[group=a];
2->5->8;
node[group=b];
1->3->6->9;
node[group=c];
4->7->10;
edge[style=solid];
1 -> 2;
1 -> 3;
1 -> 4;
edge[constraint=false];
1 -> 5;
1 -> 6;
1 -> 7;
1 -> 8;
1 -> 9;
1 -> 10;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With