Below I am trying to model a state diagram as FSA/FSM I have just started using GraphViz in the hope of keeping the state diagrams as source. The layout I want is eluding me. I would like the subgraph clusterPreGame
and clusterGame
to have a rankDir
of “TB” but these are inherited from the parent graph as “LR”. Any guidance on better layout algorithms or techniques is appreciated.
Setup: I am rendering this using vscode plugin “Graphviz Preview” [EFanZh] which renders a preview on MacOS via a brew installed implementation of dot.
any help appreciated.
[dot]
digraph cardtable {
size=5.5
node [ shape=record]
compound=true;
rankdir="LR";
subgraph clusterPreGame {
label="Pregame";
rank=same;
InRoom [ label="\<\<State\>\> \n InRoom | bool:public"];
InLobby[ label="\<\<State\>\> \n InLobby"];
InSelector[ label="\<\<State\>\> \n InGameSelector | enum: local \| remote"];
}
subgraph clusterGame {
label="Game";
subgraph clusterDealing {
label="Cut For Deal";
CutForDeal;
AwaitDeal;
CutForDeal -> AwaitDeal;
}
subgraph clusterNthState {
nthStateNode;
label="nthState";
rankdir="TB";
rank=same;
}
}
InLobby -> InSelector -> InRoom;
InRoom -> CutForDeal [ lhead=clusterDealing label="startGame"];
AwaitDeal -> nthStateNode[ label="nthTransition" lhead=clusterNthState];
}
[/dot]
digraph cardtable {
size=5.5
node [ shape=record]
compound=true;
rankdir="LR";
subgraph clusterPreGame {
label="Pregame";
rank=same;
InRoom [ label="\<\<State\>\> \n InRoom | bool:public"];
InLobby[ label="\<\<State\>\> \n InLobby"];
InSelector[ label="\<\<State\>\> \n InGameSelector | enum: local \| remote"];
}
subgraph clusterGame {
label="Game";
subgraph clusterDealing {
label="Cut For Deal";
CutForDeal;
AwaitDeal;
CutForDeal -> AwaitDeal;
subgraph clusterNthState {
nthStateNode;
label="Numerals";
rankdir="TB";
rank=same;
}
}
}
InLobby -> InSelector -> InRoom
InRoom -> CutForDeal [ lhead=clusterDealing label="startGame"];
WaitForDeal -> nthStateNode[ lhead=clusterNthState label="nthTransition"];
}