GraphStream Users

Archives de la liste Aide


Re: How to send a node's attribute to another node


Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT gmail.com>
  • To: graphstream-users AT litislab.fr, Benjamin Klatt <klatt AT fzi.de>
  • Subject: Re: How to send a node's attribute to another node
  • Date: Sat, 12 Jan 2013 14:41:28 +0100

Benjamin is right. There no specific function to "move" an attribute.
If you need to move only one attribute, the simplest way could be :

public void moveAttribute(String key, Node src, Node trg) {
    Object value = src.getAttribute(key);
    src.removeAttribute(key);
    trg.addAttribute(key, value);
}

...

Node a = ... ;
Node b = ... ;

moveAttribute("attr1", a, b);

Hope it helps ...
Regards.


2013/1/12 Benjamin Klatt <klatt AT fzi.de>

Hi Daniele,

 

as far as I know there is no explicit function to do this. The following code might help you:

 

Node targetNode = ...;

Node sourceNode = ...;

for(String key : sourceNode.getAttributeKeySet()){

  targetNode.addAttribute(key, sourceNode.getAttribute(key));

}

node.clearAttributes();

 

All the best

Benjamin

 

....................................................................

Dipl.-Inform. Benjamin Klatt

Software Engineering (SE)

 

FZI Forschungszentrum Informatik

Haid-und-Neu-Str. 10–14

76131 Karlsruhe, Germany

Tel. +49 721 9654-690
Fax +49 721 9654-691

 

klatt AT fzi.de

www.fzi.de

....................................................................

Forschungszentrum Informatik (FZI) an der Universität Karlsruhe

Stiftung des bürgerlichen Rechts

Stiftung Az: 14-0563.1 Regierungspräsidium Karlsruhe

Vorstand: Dipl. Wi.-Ing. Michael Flor, Prof. Dr. Ralf Reussner,

Prof. Dr. Rudi Studer, Prof. Dr.-Ing. J. Marius Zöllner         

Vorsitzender des Kuratoriums: Ministerialdirigent Günther Leßnerkraus

 

Von: daniele visaggio [mailto:visaggio.daniele AT gmail.com]
Gesendet: Samstag, 12. Januar 2013 14:19
An: graphstream-users AT litislab.fr; guilhelm savin
Betreff: Re: How to send a node's attribute to another node

 

Hi Guilhelm,

thanks for the prompt reply. Basically I need to move (something like cut 'n paste) an attribute from one node to another. Let's say nodeA has attribute1. I need to move it to nodeB. After the operation nodeA won't have attribute1 anymore and nodeB will have it. Maybe a method like "node.sendAttribute()" or something like this :-)

Sorry for the poor explanation in my previous mail.

Best Regards

 

 

2013/1/12 guilhelm savin <guilhelm.savin AT gmail.com>

Hi Daniele,

I  am not sure to understand what you want to do.
The following should work :

Node a, b;
b.setAttribute("attr1", a.getAttribute ("attr1"));

Is that you want to do ?

Regards
Guilhelm

Le 12 janv. 2013 09:58, "daniele visaggio" <visaggio.daniele AT gmail.com> a écrit :

 

Hi all,

each nodes inside my graph has various attributes. Every attribute consist of a string. I need a way to take a node's attribute and "transmit" it to another node.

Is there a specific method to do so? Sadly graphstream-project.org is down so I can't check the documentation.

Thank you in advance,

Daniele

 




--
Guilhelm Savin
PhD Student of Computer Science



Archives gérées par MHonArc 2.6.16.

Top of page