Hi everyone,
I’ve been reading through other posts to try and make sure I’m not asking a duplicate question, but I didn’t find anything quite on point.
I’m trying to support a use case where users will be able to decide to take control of layout on a given diagram and manually reposition nodes and edges. I want to be able to save those new node and edge positions and restore the custom-laid out graph as needed. I also want to be able to add nodes to the graph in a way that does not place those nodes on previously manually positioned nodes.
I thought it might be clever to generate a diagram using dot and then when a user moves a node, to capture the new position, and then regenerate the graph using neato, which supports node positions via pos. However, the translation does not seem to be perfect and I’m wondering why. As a simple test, if I take a dot graph and output to dot (which includes pos for each node / edge) and then use that as input for neato, it does not come out looking the same.
Here’s the input dot:
digraph {
bgcolor="transparent"
nodesep="0.5"
ranksep="0.75"
fontname="Helvetica"
node [fontsize="10" fontname="Helvetica" fillcolor="#111827" color="#111827" penwidth="0.75"]
edge [fontsize="10" fontname="Helvetica" color="#111827" penwidth="0.75"]
"1679216963259" [id="1679216963259" shape="oval" fontcolor="#111827" color="#111827" margin="0,0.05" width="3" height="1" fixedsize=true color="#111827" fillcolor="#FFFFFF" style="filled" label=<<table border="0" cellborder="0" cellspacing="0" cellpadding="0"><tr><td><font point-size="13"><b>Bob</b></font></td></tr></table>>]
"1679216654435" [id="1679216654435" shape="rectangle" fontcolor="#111827" color="#111827" margin="0.12,0.11" width="3" height="1" fixedsize=true color="#111827" fillcolor="#FFFFFF" style="filled" label=<<table border="0" cellborder="0" cellspacing="0" cellpadding="0"><tr><td><font point-size="13"><b>ABC Inc.</b></font></td></tr><tr><td></td></tr><tr><td></td></tr></table>>]
"1679216963259"->"1679216654435" [arrowsize=0 label=<100%>]
}
Here’s the output dot to input into neato:
digraph {
graph [bb="0,0,216,210",
bgcolor=transparent,
fontname=Helvetica,
nodesep=0.5,
ranksep=0.75
];
node [color="#111827",
fillcolor="#111827",
fontname=Helvetica,
fontsize=10,
label="\N",
penwidth=0.75
];
edge [color="#111827",
fontname=Helvetica,
fontsize=10,
penwidth=0.75
];
1679216963259 [fillcolor="#FFFFFF",
fixedsize=true,
fontcolor="#111827",
height=1,
id=1679216963259,
label=<<table border="0" cellborder="0" cellspacing="0" cellpadding="0"><tr><td><font point-size="13"><b>Bob</b></font></td></tr></table>>,
margin="0,0.05",
pos="108,174",
shape=oval,
style=filled,
width=3];
1679216654435 [fillcolor="#FFFFFF",
fixedsize=true,
fontcolor="#111827",
height=1,
id=1679216654435,
label=<<table border="0" cellborder="0" cellspacing="0" cellpadding="0"><tr><td><font point-size="13"><b>ABC Inc.</b></font></td></tr><tr><td></td></tr><tr><td></td></tr></table>>,
margin="0.12,0.11",
pos="108,36",
shape=rectangle,
style=filled,
width=3];
1679216963259 -> 1679216654435 [arrowsize=0,
label=<100%>,
lp="120.79,105",
pos="e,108,71.607 108,138.33 108,118.03 108,92.461 108,72.087"];
}
Why doesn’t this work as I expected? I tried playing with inputscale but that didn’t seem to do much. Also, if anyone has any better suggestions on how to achieve this, it would be much appreciated.
Thanks for your time,
Brett