In the graph below the two subgraphs are not visible, but instead all nodes seem to be placed randomly. How can I create the visible subgraphs, like one box with my PlayerChars inside, and the other with the NonPlayerChars inside?
digraph "All Characters" {
subgraph PlayerChars {
label = "Player Characters";
node [style=filled,color=yellow];
Char1 -> Char2 [ label = "is sister of" ];
Char1 -> Char2 [ label = "is brother of" ];
label = "PCs";
}
subgraph NonPlayerChars {
label = "Non-Player Characters";
Person1 -> Char2 [label="hates"];
Char2 -> Person1 [label="is indifferent"];
Person2 -> Char2 [label="stole from"];
Person1 -> Person2 [label="is father of"];
Person2 -> Person1 [label="is daughter of"];
Char1 -> Person2 [label="is in love with"];
Person2 -> Char1 [label="is annoyed by"];
}
}
What you are looking for is called a "cluster" in Graphviz. Use the special subgraph names cluster_ to draw the subgraphs in rectangular regions. E.g. from http://www.graphviz.org/Gallery/directed/cluster.html