Pin nodes offset

I am trying to introduce whitespace in my layout to later fill-in with graphics or text. I’m doing this by having extra nodes which are pined. See example graph

strict graph "" {
	graph [bb="",
		epsilon=0.00001,
		inputscale=72,
		maxiter=5000,
		notranslate=True
	];
	node [label="\N"];
	0	[element=8,
		height=0.5,
		width=0.75];
	1	[element=6,
		height=0.5,
		width=0.75];
	0 -- 1	[pos="-444.93,-1043.1 -436.1,-1034.8 -425.16,-1024.4 -416.33,-1016.1"];
	2	[element=8,
		height=0.5,
		width=0.75];
	1 -- 2	[pos="-377.01,-1010.3 -367.98,-1013.8 -357.66,-1017.9 -348.64,-1021.5"];
	29	[element=6,
		height=0.5,
		width=0.75];
	1 -- 29	[pos="-407.62,-983.53 -412.53,-971.75 -418.97,-956.29 -423.86,-944.53"];
	3	[element=6,
		height=0.5,
		width=0.75];
...................................
"extra-6790"	[fixedshape=True,
		height=2,
		pin=True,
		pos="-3757.313131313131,803.9070707070705",
		shape=square,
		width=2];
	"extra-6791"	[fixedshape=True,
		height=2,
		pin=True,
		pos="-3757.313131313131,930.1090909090908",
		shape=square,
		width=2];

However, my layout is always offset. I’ve tried different normalization or notranslate flags and I’ve tried changing lef/right definitions of pined nodes. I tried adding edges between my nodes. Nothing seems to work. See image showing the offset problem - the nodes spelling “TEST” are pinned and there is a gap for them, but it’s translated. To run this, I used this command with the dot file above:

neato -v tmp.dot -Tbmp -o graph.bmp -Gmaxiter=1 -Gmode=sgd

I did notice that even after running 1 iteration, things are offset. I’ve tried versions 2.5 and 4.0. Behavior is present in both neato-major and neato-sgd. Thank you!

I’ve also been playing with pinned nodes for the last few days trying to “solve” your other problem (Aspect ratio with neato or fdp - #5 by andrew). Lots of heartburn, probably one or more issues (to be written), no success.
I think both neato and fdp (haven’t checked other engines) don’t fully ignore pinned nodes, but do weird (unpredictable?) transforms.
Also, pinned nodes seem to define an overlay. The nodes are placed “on-top-of” the rest of the graph. Not what you want if you’re trying to create freespace/whitespace. Dang.
This needs more investigation, but I don’t expect a near-term solution that includes pinned nodes.
However, all is not lost (yet). I think there may other ways to solve (or improve) both problems.
I’m celebrating the 4th, so more complete response later, but can you say more about the whitespace:

  • around nodes, edges, or “molecules”?
  • if “molecules”, interior or exterior?
  • which engines are you open to trying?
  • can you hack up an example diagram to show the goal

Hi, thanks for helping me with this! Sorry to cause so much trouble here :slight_smile: I’ve tried many layout engines for chemistry and the packing of neato is just so visually amazing.

My goal is to create whitespace, like a small rectangle in the center for text. I would prefer to have the whitepace as the interior and molecules fill around. If reversed, that the molecules are the interior, then this could also be used to generate custom shaped (incl aspect ratio).

I’ve tried neato, fdp, sfdp with this approach of pinned nodes. sfdp doesn’t seem to respect pinning, or at least not in a way that I can understand. fdp and neato behave similarly to my example, where the space is made for the pinned nodes but it is translated. Will try to get a more concrete example too. Thank you!

Possibilities:

  • Place each molecule in its own cluster, and use cluster labels for the text (text outside molecule). Easy, but not packed as densely. (p.s. possibly set peripheries=0)
  • Text on-top-of molecule. Here pinned nodes will work.
    • put each molecule in its own subgraph (not cluster, though cluster also works)
    • add desired text to subgraph with “fake” attribute name {graph [mytext="read me"] ...}
    • run through neato with output format = dot. This effectively pins all nodes and edges.
    • postprocess to determine center of each molecule (of all nodes within a subgraph)
    • create new node for each subgraph centered with label=mytext and style=plaintext
    • run through neato -n2
    • OK not trivial, but not that hard. Though text-over-molecule might not be readable
  • Use the tooltip attribute to place your text. Only helps if the user knows about it. Does not support (visual) search.
  • “Inside”, hmmm. I don’t know a way to find an inside of a graph - unless circo or twopi are used. I need help on this one.