Open StoneCypher opened 5 years ago
Notably, this only makes sense as the source of a spread, not as the target - you can't just draw an arrow to a subgraph and expect people to infer "oh, there's one of these to each subnode."
This can lead to much simpler graphs, but also suggests the following surprising rendering to be correct, which will need to be pointed out in the docs, which isn't exactly ideal.
[a b c].{subgraph: true} -> [x y z].{subgraph: true};
Instead of, as one might expect,
this also leads to a remarkably aesthetic representation of neural networks
The supporting DOT for that last graph.
# http://www.graphviz.org/content/cluster
digraph G {
compound = true;
subgraph cluster_0 {
{ rank = same; a; b; c; }
color=black;
fillcolor=gray93;
style=filled;
}
subgraph cluster_1 {
{ rank = same; m; n; o; }
color=black;
fillcolor=gray93;
style=filled;
}
subgraph cluster_2 {
{ rank = same; x; y; z; }
color=black;
fillcolor=gray93;
style=filled;
}
a [ style=filled; fillcolor=white; ];
b [ style=filled; fillcolor=white; ];
c [ style=filled; fillcolor=white; ];
m [ style=filled; fillcolor=white; ];
n [ style=filled; fillcolor=white; ];
o [ style=filled; fillcolor=white; ];
x [ style=filled; fillcolor=white; ];
y [ style=filled; fillcolor=white; ];
z [ style=filled; fillcolor=white; ];
b -> m [ ltail=cluster_0; ];
b -> n [ ltail=cluster_0; ];
b -> o [ ltail=cluster_0; ];
n -> x [ ltail=cluster_1; ];
n -> y [ ltail=cluster_1; ];
n -> z [ ltail=cluster_1; ];
}
Won't work without that compound=true;
at the beginning
The comparable FSL:
&_subgraph.{ backgroundColor: #eee; };
&_node .{ backgroundColor: white; };
[a b c].{subgraph: true} ->
[m n o].{subgraph: true} ->
[x y z].{subgraph: true};
actually, if it's
&foo.{subgraph: 'subgraph'};
then we can use html/js-style key-name repetition and just say
&foo.{ subgraph; };
Traffic light looks much better with styled subgraphs
Better still with faint coloring and direction control:
Controlling DOT:
# http://www.graphviz.org/content/cluster
digraph G {
compound = true;
rankdir = BT;
subgraph cluster_0 {
Green -> Yellow -> Red -> Green;
color=black;
fillcolor=gray93;
style=filled;
}
Green [ style=filled; fillcolor="#ddffdd"; ];
Yellow [ style=filled; fillcolor="#ffffbb"; ];
Red [ style=filled; fillcolor="#ffdddd"; ];
Yellow -> Off [ ltail=cluster_0; ];
Off -> Red;
}
Subgraphs are for the visualization only, and would have no impact on the execution of the FSM.
When writing
You will get this layout, formatting removed for clarity:
With subgraphs, you could get this superior layout instead:
This also closes everything that a person used to HSMs and HFSMs wants out of groups.