|Find Nodes in a Graph [message #558190]
||Fri, 10 September 2010 13:31
Registered: July 2010
I am currently using Zest to create a graphic representation of a model as part of a GUI I'm making. It creates a Graph object by doing an in-depth search of the model. |
public void makeGraph(DNode node, GraphNode father) //the DNode class is dependent on the project I'm working on, not Zest itself.
GraphNode newNode = new GraphNode(graph, SWT.NONE, node.getNodeName();
new GraphConnection(graph, SWT.NONE, newNode, father);
/* some actions irrelevant to the matter at hand */
for(DNode comp: node.children())
Unfortunately, the search method will often find the same node twice; to avoid creating duplicates, I need a way to check if the node already exists within the graph.
My first idea was to do something like this:
public void makeGraph(DNode node, GraphNode father)
/* the node already exists; just add a connection to it. */
/* New node; create it, connect to it, call makeGraph() for its children. */
Unfortunately, that didn't work either. I'm not sure why, but the "if" was never answered positively, and I still ended up with a lot of duplicates.
So I'm left wondering...How does one actually check if a node exists in a Graph?
Powered by FUDForum
. Page generated in 0.02629 seconds