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:
clone my graph, and make all the changes in the clone.
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:
I clearly misunderstood what the multiEdges parameter does. What does it do then? Is there a way to create a metanode as a singleton?
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?
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
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).
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
To do 2, I do this:
multiEdges = False
should mean that the metanode is created as a singleton.delAllEdge = False
should 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:
multiEdges
parameter does. What does it do then? Is there a way to create a metanode as a singleton?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
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:clone_graph
) and another one to contain the metanode (call itmetanode_graph
).mn = metanode_graph.createMetaNode(sg, False False)
clone_graph
, iterate over the edges incident to the nodes insg
; collect the values of the relevant properties; and write them into the properties of the edges incident to the metanode inmetanode_graph
.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.