Development scripts/tips location?

I’ve been debugging Issue 1213 and friends.

I’ve apparently fixed the immediate issue but have some funky intermediate output.

I incrementally worked with Claude to whip up some instrumentation output (gated by DEBUG) and a script to plot what’s happening in the “path” planning process. See the attached.

I’m working on getting visualization of some more stages of the layout algorithm, since the constraint on with V10->V7 is happening earlier on.

Obviously this will only be useful for debugging small graphs, but seems generally useful. Any chance there is an existing place to put useful debugging scripts and the like?

-Brian

This is really neat! Very powerful to visualise this IMO.

I believe the layout algorithm can be implemented as a general step-by-step iterative process, where each intermediate step can be directly exported as dot or xdot. This would be very helpful for visualizing the entire layout process and can be achieved.

Yes, you can easily “stop action” dot as it progresses through the phases.

  • dot -Gphase=1 myfile.gv will show the result of the ranking algorithm (1st pass through network simplex). Note that a temporary attribute named rank will be set to each node’s rank.
  • dot -Gphase=2 myfile.gv will add the ordering assigned by the mincross algorithm. Each node will have a temporary order attribute added.
  • dot -Gphase=3 myfile.gv will assign the final pos attribute to every node.
  • dot -Gphase=4 myfile.gv will assign pos values to every edge.

Here is issue 1213 stepped through the phases with some artistic licence (nodes positioned with only 0 or 1 coordinates)





This attribute seems to be undocumented?

I’d forgotten that phase is on a list of discovered attributes that have not been officially documented (see Document undocumented attributes (#75) · Issues · graphviz / graphviz.gitlab.io · GitLab).
That said, the phase attribute has worked for a long time.

p.s. if you use phase on the command line, know that it is then inserted into the source (dot format) and must be edited out or commented out if you want to use the resulting output as input back into dot as I did for the images above. (sorry, a very convoluted sentence)

Can you please describe how exactly you generated those?

I notice that when I use -Tsvg I can generate -Gphase=3 and -Gphase=4 outputs which are usefully rendered as .svg (according to the layout algorithms I’m debugging), but -Gphase=1 and -Gphase=2 don’t seem to yield useful .svg files. (They have viewbox="0.00 0.00 8.00 8.00" and a bunch of circles with cx="0" cy="0" which doesn’t seem very promising. An SVG viewer shows them as 8x8 pixels with maybe a letter V or some curves.)

Outputting .gv files yield dot files which beg the question of how they should be displayed. Whichever version of dot I use to lay them out yields its favorite layout (after I remove the phase= line from the file).

So: -Gphase=3 and -Gphase=4 are useful with -Tsvg. I don’t see how others are useful.

Also, is there any chance that there is a hidden feature to show spline regions on top of the final dot graph (as in Figure 5-1 in TSE93.pdf)?

Here is a gist containing my shell script & gvpr program
(illustrateDot - showing how dot (a Graphviz program) works · GitHub)

Phase 1 & 2 only “work” because the gvpr program adds the missing coordinates.

Is this (bugs in current "showboxes" implementation (#2699) · Issues · graphviz / graphviz · GitLab) what you are after regarding spline regions?

Is this (bugs in current “showboxes” implementation (#2699) · Issues · graphviz / graphviz · GitLab) what you are after regarding spline regions?

Cool, thanks. I suspect that being able to apply it to a single edge at a time might be useful for debugging layout issues.

By the way, although the phase looks interesting, what I actually meant earlier was to display the step-by-step iteration process of each node reaching its final position during Phase 2 to 3.

Some step-by-step thoughts & possibilities:

  • step-by-step might be too fine-grained for many graphs
  • both mincross (phase 2) & ns (phase 3) can be terminated early
    • using mclimit (mclimit | Graphviz) for mincross
    • using nslimit (nslimit | Graphviz) for ns
    • the code for the above might have to be modified for the desired granularity
    • then use the appropriate value for phase to produce a dot-format output, as for illustrateDot (above)
  • phase 2 would seem to present a set of images showing nodes hopping left & right on their appointed ranks
  • phase 3 would show the nodes sliding left & right, but keeping their appointed order.
  • the spline boxes only apply to phase 4 and can be applied via post-processing (similar to Fun with edges!)