Menu

Understanding the `multiEdges` and `delAllEdge` parameters in the `createMetaNode` method

Help
Alberto
2021-01-25
2021-02-25
  • Alberto

    Alberto - 2021-01-25

    I want to create a metanode from a subgraph. My main issue is that I need to compute properties of the edges incident to the metanode from the properties of the the "original" edges, incident to the individual nodes now grouped into the metanode.

    I thought it simplest to:

    1. clone my graph, and make all the changes in the clone.
    2. create the metanode (in the clone) as a singleton, with no edges, and then create new edges (in the clone) based on the properties of the incident edges in the original graph.

    To do 2, I do this:

    mn = clone_graph.createMetaNode(ssg, False, False)
    

    multiEdges = False should mean that the metanode is created as a singleton.

    delAllEdge = Falseshould mean that the edges internal to the metanode are not deleted from all the hierarchy, so they stay in the original graph.

    But I have a surprising result: the metanode is not a singleton. Additionally, the metanode contains the original nodes and their connecting edges (see attached image).

    Questions:

    1. I clearly misunderstood what the multiEdges parameter does. What does it do then? Is there a way to create a metanode as a singleton?
    2. I like to be able to observe the "inside" of the metanode. But, does that affect the node and edges count? Does my graph now have the original nodes, plus the metanode counted as a node? Is it the same for the original edges? Or only for the edges internal to the metanode?
     
  • Bruno Pinaud

    Bruno Pinaud - 2021-02-03

    Hello Alberto,

    Sorry for the delay.
    What do you mean by singleton? Multiedges=True means that an edge connecting the metanode is created for each replaced edges of the original graph. If Multiedges=False, only one edge is created between the metanode and all connected nodes.
    delAllEdge is also for the edges connected to the metanode. They will be deleted only from the current graph( delAllEdge=False) or from the whole graph hierarchy.

    A metanode in a graph G replaced a group of nodes and edges. These nodes and edges are just deleted from G and put in a subgraph. The parameters are for handling edges connected to the metanode (they are in fact connected to a node inside the metanode) and the rest of the graph.

    Hope this is clear.
    Bruno

     
    👍
    1
  • Alberto

    Alberto - 2021-02-25

    Oh, right! Now I understand much better. Thanks, Bruno.

    If you set multiEdges = True, though, the properties of the original edges are still not carried through to the newly created edges, AFAICS. So, the strategy is something like:

    1. Duplicate the graph, so you have a copy of the original one (call it clone_graph) and another one to contain the metanode (call it metanode_graph).
    2. mn = metanode_graph.createMetaNode(sg, False False)
    3. In clone_graph, iterate over the edges incident to the nodes in sg; collect the values of the relevant properties; and write them into the properties of the edges incident to the metanode in metanode_graph.
     
  • Bruno Pinaud

    Bruno Pinaud - 2021-02-25

    If you set multiEdges = True, though, the properties of the original edges are still not carried through to the newly created edges

    Yes. This is possible in C++ and not (yet) in Python.

    Your strategy is good. This is basically what is done in C++ to do this automatically.

     

Log in to post a comment.