GraphStream Users

Archives de la liste Aide


Re: Finding if a node is already created


Chronologique Discussions 
  • From: Rajesh Veeranki <rveeranki01 AT gmail.com>
  • To: guilhelm savin <guilhelm.savin AT gmail.com>
  • Cc: graphstream-users AT litislab.fr, Stefan Balev <stefan.balev AT gmail.com>
  • Subject: Re: Finding if a node is already created
  • Date: Sun, 1 Jul 2012 04:39:44 +0530

Hi  guilhelm savin ,
Nice.This even seems to copy the attributes without much doing . Thanks for the help.

Regards,
Rajesh V.

On Fri, Jun 29, 2012 at 4:52 PM, guilhelm savin <guilhelm.savin AT gmail.com> wrote:
Hi Rajesh,

There is no clean method to merge two graphs (or more),
but you can try this way :

| Graph a, b, c;
| a = new DefaultGraph("a");
| b = new DefaultGraph("b");
| c = new DefaultGraph("c");
| c.setStrict(false);
| a.addSink(c);
| b.addSink(c);
| a.addNode("A");
| a.addNode("B");
| a.addNode("C");
| a.addEdge("AB", "A", "B");
| a.addEdge("AC", "A", "C");
| a.addEdge("BC", "B", "C");
| b.addNode("A");
| b.addNode("D");
| b.addNode("E");
| b.addEdge("AD", "A", "D");
| b.addEdge("AE", "A", "E");
| b.addEdge("DE", "D", "E");

This merges graph a and b into graph c. Do not forget
the setStrict(false) on c to prevent exception when
adding an already existing node.

If your graphs are already created, you can use GraphReplay :

| GraphReplay replay = new GraphReplay("replay");
| replay.addSink(c);
| replay.replay(a);
| replay.replay(b);

Regards.
Guilhelm

2012/6/29 Rajesh Veeranki <rveeranki01 AT gmail.com>
Oh.. thanks a lot.That helped me.
I also want to know if there is a method to merge two graphs ( i.e, the edges of the same node in the two graphs are merged )
Thanks,
Rajesh V


On Fri, Jun 29, 2012 at 4:18 AM, Stefan Balev <stefan.balev AT gmail.com> wrote:
Hi Rajesh,

The easiest way to check if a node exists looks like that :

Graph g = ...;
...
if (g.getNode("foo") != null) {
  // the node exists
} else {
  // the node does not exist
}

Hope it helps,

--
Stefan


2012/6/29  <rveeranki01 AT gmail.com>:

> Hi,
> I want to know if there is any easy method to see if a node(with the unique id)
> is already created.I have seen the documentation but couldn't find any.
> Thanks in advance,
> Rajesh V





--
Guilhelm Savin
PhD Student of Computer Science




  • Re: Finding if a node is already created, Rajesh Veeranki, 01/07/2012

Archives gérées par MHonArc 2.6.16.

Top of page