Open chtenb opened 7 years ago
This is currently not possible. The model is that the subgraphs should form a tree by the subgraph relation, with each subgraph having a unique parent graph. If you allow a subgraph to be inserted into another subgraph, you could introduce cycles. Or worse, you could have one subgraph contain itself. If the library allowed inserting an existing subgraph into another, the function would have to do something to preserve the tree, or figure out a new model that makes sense.
The question is, what are you trying to do? One could imagine a re-parent function, though it would take a fair amount of bookkeeping. You could simulate this by cloning the subgraph where you want it, and then removing the old subgraph. (gvpr has a cloning function; it might be useful to move this into cgraph.)
One could imagine a re-parent function, though it would take a fair amount of bookkeeping. You could simulate this by cloning the subgraph where you want it, and then removing the old subgraph. (gvpr has a cloning function; it might be useful to move this into cgraph.)
Yes, that's about what I want to do. Just moving a subgraph into another subgraph. That cloning function you're talking about, does it really deep-copy the nodes with their attributes?
In general I suppose any functionality that is cgraph-only could be moved to the cgraph library, so yeah, moving that cloning function sounds like a good plan.
Yes, the clone function in gvpr does a deep copy of everything. It wouldn't be hard to move it to the cgraph library. To get a move, you would then clone your subgraph, then delete the original. Not as efficient as a real move or reparent function, but it avoids the complexities.
From the cgraph tutorial Chapter 9 "Subgraphs":
How can we add an already existing subgraph to another subgraph? For nodes and edges there are functions available, but for subgraphs that doesn't seem to be case.