Re: [graphviz-interest] Moving nodes and edges between [sub]graphs using the gv library

"Emden R. Gansner" <[email protected]> Thu, 27 Feb 2014 17:33:17 -0500
Newsgroups gmane.comp.video.graphviz
Message-ID <[email protected]>
I think a couple of corrections are necessary.

>
> A node can't be a direct member of more than one subgraph. Subgraphs 
> can be added to other subgraphs, forming a tree,
> so indirectly a node is a member of all its parent subgraphs, and the 
> parent graph. 
This isn't true. Otherwise, you could do things like:
    {rank=same a b}
    subgraph cluster {a b }
Nodes and edges can be put into any subgraphs anywhere. The two 
restrictions are, with cgraph, subgraphs must now
form a tree (in libgraph, they could form a dag), and nodes should have 
a unique immediate cluster.

> So, to move a node from one subgraph to another I would need to create
> a new node, copy all the attributes, create copies of all the existing
> edges to/from the old node, copy all of their attributes, then delete
> the old node (and the old edges?)?
No, you just remove it and stick it anywhere else in the graph you want.
The restriction is that nodes and edges do live in a unique root graph. 
You can't remove a node from
a root graph and stick it into another root graph. In this case, you 
would have to make a clone of the
node in the new graph. The library provides functions for cloning

> Yes, except that presumably the reason for moving it to a subgraph is 
> so that you inherit a number of the attributes from the subgraph tree, 
> so you wouldn't need to rewrite those. 
No, when a node is created, it inherits its attributes active currently 
defined in the chain of subgraphs containing it. After
that, if you change the containing graph's node attributes, or move the 
node to a new subgraph, it keeps the attributes
it had when created. After creation, the only way to alter the node's 
attributes is to reset them explicitly.

     Emden

_______________________________________________
[email protected]
http://lists.research.att.com/mailman/listinfo/graphviz-interest