[gvpr] Multiple traversals != multiple node visits?

Hi all :wave:

I’m relatively new to graphviz, and I’m coming at gvpr through the lens of a sysadmin, not a mathematician :slight_smile:

I’m having trouble getting multiple traversals, triggered by setting $tvroot or $tvnext, to visit any node multiple times.

Before I spent much more time digging, or writing up and posting my problem here, can I check: the tvroot/tvnext description in its docs says to me that another traversal will be started if these values are set or changed.

Does “another traversal” imply that already-visited nodes should be visited again, in the follow up traversal? Or is it implicitly the case that additional traversals (starting at different roots) are only useful if the gvpr user is trying to nudge the DFS/BFS algorithms to show them that they’ve managed to miss certain nodes, and that starting at this root is a way to reach them, this time?

In other words, if the conditions in the docs for setting tvroot/tvnext and starting additional traversals hold, should I expect any node to be visited and matched by a N[] predicate multiple times?

Many thanks folks!
J

Greetings. The author of gvpr is not available much any more. From reading the code (lib/gvpr/gvpr.c) it appears that if you set tvroot, the current traversal continues without resetting all the visited nodes. At least, this is how I’m reading nextNode. I don’t see any attempt to unwind the current traversal. However there is a comment in the gvpr man page that it’s possible to create an infinite loop using DFS and tvroot. I don’t fully understand what this means - that the traversal would hit the new tvroot but immediately stop at other marked nodes? The answer requires more code archaeology.

Can you share more about what you are trying to do with multiple traversals.
I think the answer is that you can have as many traversals as you want, but you might only have the N and E syntax available for one traversal. You could still visit all (or some) of the nodes and/or edges, but with different syntax. Is it important that the traversals be in different order or just that there are multiple traversals?
Here is a simple gvpr program that traverses the nodes 3 times:

BEGIN{
 node_t aNode;
}
BEG_G{
   print("// traverse #1");
   for (aNode=fstnode($G);aNode;aNode = nxtnode(aNode)){
     print ("// node:  >", aNode.name,"<");
   }
   print("// traverse #2");
   for (aNode=fstnode($G);aNode;aNode = nxtnode(aNode)){
     print ("// node:  >", aNode.name,"<");
   }
}
N{
  print ("// traverse #3 node:  >", $.name,"<");
}