Add a grid to your graphs

addGrid.gvpr - a postprocessor that will add a grid to your Graphviz graph.
unix.Ranks
Find it here
It can do horizontal, vertical, or both; edge styles, (multiple) colors, fixed increment or centered on ranks.
Mostly a toy, but probably useful on larger graphs.
Example command line:

dot myFile.gv | gvpr -a 'size=rank Gcolor=green,purple,red grid=horizontal' -cf addGrid.gvpr |neato -n2 ...

Enjoy

1 Like

Hi Steve,

this is pretty impressive and it made me think.

I even had a look at the manual: gvpr | Graphviz
but I don’t think it provided the answer to this question: what is the output of gvpr?
I thought it was a tool dot → dot, but these lines aren’t part of the dot language afaik.
So, what is the outcome? Or which tool is the output formatter?

Cheers,
Klaus

Simple answer: the output of gvpr is the Graphviz / dot language. The grid lines are a result of adding new nodes around the periphery of the graph and then adding (straight) edges connecting the nodes.

More complete answer: gvpr is a complete language and could probably be used to write a (very simple) compiler. (Not on my TODO list). Here is a lint program written in GVPR. No dot output, just text.

For an example of the breadth of gvpr, here is a radial layout engine written in gvpr. Legal dot input and legal dot output.

1 Like

I needed to come back and read this again. Impressive. Well done!
Do you have somewhere a list of “documented” gvpr use cases? I see it here mentioned every now and then. But do you have a systematic list of examples?

Nope, nothing systematic about any of my efforts. I am slowly working on documenting the more interesting programs, if I can figure out what they do.
Note that some are posted here.

Moving the conversation to this thread from Simulate Y axis and horizontal strips - #5 by somms

I get an error that may be related to your code (or most probably to my inexperience)

When I try to add any parameter using the -a option, I always get an empty output and a “gvpr: gvpr” message:

$ dot input.dot | gvpr -a 'size=rank' -cf addGrid.gvpr
//  SIZE start: 72pt delta: 0
//  SIZE end: 72pt size: 72 delta: 0
// ARG >size=rank<
//  type: s
gvpr: gvpr

The “offending line” is

187 Val=substr(ARGV[i],Indx);

After adding some prints to debug, the problem is that Indx value is -3.

BIngo. It seems that there is a bug in my gvpr version (2.48.0) and index returns the value of rindex. I have substituted

Indx=1+index(ARGV[i],"=");

by

Indx = length(ARGV[i]) - rindex(ARGV[i], "=") + 1;

And it works well now.

Are you saying that gvpr has a mistake in its implementation of index. That is possible.

Yep, here are two closed Issues that mention gvpr & index
#2211
#2138

1 Like