Reputation: 14529
I recently started using Graphviz.
I'm working on a graph with labels, but they're not showing up. Neither are my sub-groups being surrounded by an encompassing rectangle.
Here's my code:
digraph system {
subgraph Machine_001 {
label = "Machine_001";
subgraph Machine_001_Service_001 {
label = "Service_001 on Machine_001";
node [shape=record];
Machine_001_PORT_10 [label = "Port 10"];
Machine_001_PORT_11 [label = "Port 11"];
Machine_001_PORT_12 [label = "Port 12"];
Machine_001_PORT_13 [label = "Port 13"];
{rank=same Machine_001_PORT_10 Machine_001_PORT_11 Machine_001_PORT_12 Machine_001_PORT_13}
Machine_001_PORT_10 -> Machine_001_PORT_11;
Machine_001_PORT_12;
Machine_001_PORT_13;
}
}
subgraph Machine_002 {
label = "Machine_002";
subgraph Machine_002_Service_001 {
label = "Service_001 on Machine_002";
node [shape=record];
Machine_002_PORT_50 [label = "Port 50"];
Machine_001_PORT_11 -> Machine_002_PORT_50;
}
}
}
Using http://www.webgraphviz.com/ to render it, I would expect labels, but those are not shown.
On the other hand, an example like this does show labels and an encompassing rectangle:
digraph D {
subgraph cluster_p {
label = "Parent";
subgraph cluster_c1 {
label = "Child one";
a;
subgraph cluster_gc_1 {
label = "Grand-Child one";
b;
}
subgraph cluster_gc_2 {
label = "Grand-Child two";
c;
d;
}
}
subgraph cluster_c2 {
label = "Child two";
e;
}
}
}
Frankly, I don't see what the problem is. I gave it a label, and I nested it. Which is exactly what the working example does.
What am I missing?
Upvotes: 0
Views: 551
Reputation: 9012
Looks like placing "cluster_" in front of the names in the subgraphs solves the problem, so the following is not 100% an answer as I think, my interpretation of the definitions, it should be possible.
In https://www.graphviz.org/doc/info/lang.html some definitions are given (left out some parts by me!):
subgraph : [ subgraph [ ID ] ] '{' stmt_list '}'
An ID is one of the following:
Any string of alphabetic ([a-zA-Z\200-\377]) characters, underscores ('_') or digits ([0-9]), not beginning with a digit;The third role for subgraphs directly involves how the graph will be laid out by certain layout engines. If the name of the subgraph begins with cluster, Graphviz notes the subgraph as a special cluster subgraph. If supported, the layout engine will do the layout so that the nodes belonging to the cluster are drawn together, with the entire drawing of the cluster contained within a bounding rectangle. Note that, for good and bad, cluster subgraphs are not part of the DOT language, but solely a syntactic convention adhered to by certain of the layout engines.
So it looks like that the names of the subgraphs are a bit limited in this case.
Maybe that and issue at https://gitlab.com/graphviz/graphviz/issues can help
Upvotes: 1