Menu

Digraph Supergraphs and Subgraphs

iwbnwif
2015-09-28
2016-04-05
  • iwbnwif

    iwbnwif - 2015-09-28

    Firstly, thanks again for a great library and secondly, sorry if this post is a bit of noise.

    I have a couple of rather specific use cases I am playing with that require building a large graph (supergraph) out of several subgraphs.

    In the first use case a supergraph is created from one, several or many instances of one or more subgraphs. In the second use case a digraph is initially created. Then later a subgraph is created that represents a 'drilling down' into the topology that was orignally shown as a single node in the original graph.

    For both these two cases it would be nice to be able 'splice' a subgraph into another graph.

    I appreciate that this can already be achieved by traversing the subgraph and manually inserting nodes and arcs.

    It would (for me!) be useful if the library could perform the traversing and inserting as single method.

    Of course to achieve this it would be necessary to nominate which nodes in the subgraph should be spliced to which arcs in the supergraph, however apart from this I can't see any particular theoretical obstacles?

     
  • Andy Rushton

    Andy Rushton - 2015-09-29

    This is an excellent idea and tallies with some enhancements I made to the ntree component a while back - it is possible there to copy or move trees into other trees.

    It seems to me that the way to do the splicing is to move all the nodes and arcs of one graph into another in a way that does not invalidate any node iterators. I believe I found a way of doing this with the ntree component. You can then do the splicing yourself by simply using the existing arc creation methods. So there's no need for any kind of complicated 'splice' interface, just a move operation.

    I'm not sure if or when I'll get round to it though - I haven't done any significant work on STLplus for a while so there will be a learning curve to get up to speed with the internals of the digraph before I could do anything.

     
  • iwbnwif

    iwbnwif - 2015-09-30

    Thank you for the fast response.

    Actually it was the similar ntree features that got me into STLplus a year or so ago, and I must say they work brilliantly.

    Let me check that I understand correctly, the process would be something like:
    1. Move or copy one graph (graph2) into another graph (graph1)
    2. Move one end of the relevant graph1 arcs (using arc_move_from or arc_move_to) to attach to the relevant nodes in what was graph2
    3. Delete the no longer used/attached node(s) in graph1

    I think that this would be just fine for the library and I can build a more complicated 'splicing' interface in my application if I need it.

    Of course I understand that this is probably not the most pressing thing for you at the moment :)

     

    Last edit: iwbnwif 2015-09-30
  • Andy Rushton

    Andy Rushton - 2015-10-29

    I have implemented one of the methods that is needed to implement this functionality. I have called it "move" (a name which I'm still thinking about - it's based on the ntree method but "merge" might have been better). Anyway, it moves all the nodes and arcs of one graph into another.

    No new arcs are created by doing this, so you still have to work out how to do that part of the process.

    Iterators to the subgraph nodes and arcs will become iterators to the merged graph, still pointing to the same nodes/arcs. So this should make connecting up fairly simple.

    The new method is part of the 3.12 release which I just posted to the SourceForge website.

     
  • iwbnwif

    iwbnwif - 2016-04-05

    I am sorry for the huge delay in responding to your changes. After a big gap, I am finally back to working on this and have tried out the new move function.

    Just to report that it works brilliantly, thank you!

     
  • Andy Rushton

    Andy Rushton - 2016-04-05

    I'm glad that this has worked for you, it turned out to be quite simple and I think very efficient.

     

Log in to post a comment.