Closed sirmodelquestions closed 8 years ago
Unfortunately, getting different network software to talk to each other is always somewhat tricky. yEd uses its own special conventions in its GraphML to store visual information. So here's my recommendation:
First, save the network as a GML file instead of GraphML. GML stores its X and Y properties just as x
and y
in the standardized graphics section, whereas yEd's GraphML format buries them deep in a custom XML tree.
Next, you should know that NW uses Gephi's libraries to do most of its importing and exporting. It does this because Gephi is widely used and supports many formats. However, this also comes with some drawbacks. One of these is that Gephi does funny things with attributes named x
and y
. Because of this, we need to rename the x
and y
attributes. While you may be able to do this by editing the GML file to move the x
and y
attributes out of the graphics
section and rename them, I think it's easier to open the GML file up in Gephi itself, and then resave as a GDF. GDF is a very easy format to work with, thus I generally prefer it. Now, to rename the attributes, open the GDF file in a text editor. The top line should look something like this:
nodedef> name VARCHAR,label VARCHAR,width DOUBLE,height DOUBLE,x DOUBLE,y DOUBLE,color VARCHAR,outline VARCHAR,type VARCHAR
Change the x
and y
to something like node-x
and node-y
.
In NetLogo, make sure your turtles have turtles-own
variables with the same names (node-x
and node-y
). When you import the network, these turtles-own
variables will be filled with the corresponding node attributes. Then, all you have to do is set the xcor
and ycor
of the turtles based on node-x
and node-y
. For instance:
nw:load-gdf "your-file.gdf" turtles links [
set xcor node-x
set ycor node-y
]
You might have to scale and/or translate node-x
and node-y
, since yEd and NetLogo likely aren't using the same coordinate system.
Sorry it's so complicated!
Yes, thank you so much! It worked perfectly!
Great! Happy to hear it!
When I import my network from yEd it puts all my nodes right on top of each other in the middle of the screen. I know I can import the graph to be a circle and a couple other things, but I just want it to be like how I drew the graph in yEd. Is there a way to do this?
I've attached an image of the graph I want to import. Thanks for any help!