I am exploring the use of the Tulip api in c++ for visualizing some hierachical data, and I am trying to generate a meta-node using the api. However, looking at the documentation it is not clear how the createMetaNode function is supposed to work.
The example below generates an error that a meta-node cannot be created in the root of the graph.
I feel like I'm misunderstanding something about how this function works. Can someone give me a minimal working example that generates a simple structure containing a metanode?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear Perry,
Metanodes cannot be created on the root graph. You should create another subgraph level and create the metanode on the subgraph. The root graph cannot be used anymore for visualization (it contains the metanodes and the nodes and edges which are inside the metanodes). The following code should work (not tested) :
Graph graph = newGraph();
sub = graph->addSubGraph();
Graph subGraph = sub->addSubGraph();
node n1 = subGraph->addNode();
node n2 = subGraph->addNode();
sub->addEdge(n1,n2);
sub->createMetaNode(subGraph);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your code is quite similar to the code I gave in the second snippet, and has the same problem: the created metanode is empty.
I also tried this:
~~~
Graph graph = newGraph();
Graph sub = graph->addSubGraph();
Graph* subGraph = sub->addSubGraph();
sub->createMetaNode(subGraph);
node n1 = subGraph->addNode();
node n2 = subGraph->addNode();
sub->addEdge(n1,n2);
~~~
But that results in the nodes n1 and n2 being created twice, once inside the metanode and once outside the metanode (and the addedge function appears to be ignored inside the metanode). Do you happen to have any ideas to fix that?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is working (Python, easier for testing) and tested:
n1 = graph.addNode();
n2 = graph.addNode();
graph.addEdge(n1,n2);
g = graph.addCloneSubGraph("g");
meta = graph.addCloneSubGraph("meta");
sub.createMetaNode(meta);
- metanodes cannot be created on the root graph
- subgraph g contains the resulting graph after the creation of the metanode. The content of the metanode should be inside it before the creation of the metanode
- subgraph meta is the content of the metanodes.
hope this helps
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think I might not have made clear what I want. The above snippit works (assuming you ment g.createMetaNode instead of sub.createMetaNode), but when using saveGraph(graph, "test.tlp"), it will render the nodes n1 and n2 twice. Once inside the generated metanode and once outside the metanode. I would like the nodes to be only visible inside the metanode.
Is this possible or am I misunderstanding what a metanode is supposed to do?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Perry, I followed the discussion you are having with Bruno, allow me to jump in. If I understand well, you are annoyed by the fact that the top level graph contains both the metanode you created and the nodes it contains, and would like to only have the metanode, the contained node being accessible by other means (double clicking the metanode in the GUI for instance).
This however is not possible. The highest level graph in the hierarchy will necessarily contain the collection of all nodes that have been created. That is what this graph shoudl do, in a sense. One way to deal with the situation is to create subgraphs, one that would contain the original low level nodes, and another that would only contain your metanode(s). You should see the higher level graph as a convenience holding all created entities (nodes and edges) populating whatever subgraphs in the hierarchy.
Hope this helps
Guy
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am exploring the use of the Tulip api in c++ for visualizing some hierachical data, and I am trying to generate a meta-node using the api. However, looking at the documentation it is not clear how the createMetaNode function is supposed to work.
The example below generates an error that a meta-node cannot be created in the root of the graph.
Replacing the body of the main function with the following creates an empty metanode:
I feel like I'm misunderstanding something about how this function works. Can someone give me a minimal working example that generates a simple structure containing a metanode?
Dear Perry,
Metanodes cannot be created on the root graph. You should create another subgraph level and create the metanode on the subgraph. The root graph cannot be used anymore for visualization (it contains the metanodes and the nodes and edges which are inside the metanodes). The following code should work (not tested) :
Graph graph = newGraph();
sub = graph->addSubGraph();
Graph subGraph = sub->addSubGraph();
node n1 = subGraph->addNode();
node n2 = subGraph->addNode();
sub->addEdge(n1,n2);
sub->createMetaNode(subGraph);
Thank you for your reply.
Your code is quite similar to the code I gave in the second snippet, and has the same problem: the created metanode is empty.
I also tried this:
~~~
Graph graph = newGraph();
Graph sub = graph->addSubGraph();
Graph* subGraph = sub->addSubGraph();
sub->createMetaNode(subGraph);
node n1 = subGraph->addNode();
node n2 = subGraph->addNode();
sub->addEdge(n1,n2);
~~~
But that results in the nodes n1 and n2 being created twice, once inside the metanode and once outside the metanode (and the addedge function appears to be ignored inside the metanode). Do you happen to have any ideas to fix that?
This is working (Python, easier for testing) and tested:
n1 = graph.addNode();
n2 = graph.addNode();
graph.addEdge(n1,n2);
g = graph.addCloneSubGraph("g");
meta = graph.addCloneSubGraph("meta");
I think I might not have made clear what I want. The above snippit works (assuming you ment g.createMetaNode instead of sub.createMetaNode), but when using saveGraph(graph, "test.tlp"), it will render the nodes n1 and n2 twice. Once inside the generated metanode and once outside the metanode. I would like the nodes to be only visible inside the metanode.
Is this possible or am I misunderstanding what a metanode is supposed to do?
Hi Perry, I followed the discussion you are having with Bruno, allow me to jump in. If I understand well, you are annoyed by the fact that the top level graph contains both the metanode you created and the nodes it contains, and would like to only have the metanode, the contained node being accessible by other means (double clicking the metanode in the GUI for instance).
This however is not possible. The highest level graph in the hierarchy will necessarily contain the collection of all nodes that have been created. That is what this graph shoudl do, in a sense. One way to deal with the situation is to create subgraphs, one that would contain the original low level nodes, and another that would only contain your metanode(s). You should see the higher level graph as a convenience holding all created entities (nodes and edges) populating whatever subgraphs in the hierarchy.
Hope this helps
Guy