NetLogo / NW-Extension

This is the NetLogo Network Extension. For general information about NetLogo, see:
http://ccl.northwestern.edu/netlogo/
Other
62 stars 25 forks source link

nw:load-gml cannot import GML files generated using a Python script #188

Closed aymericvie closed 5 years ago

aymericvie commented 5 years ago

Hello everyone, hello @qiemem,

I use Python to generate networks and save them on a GML file. I then try to import that GML file in Netlogo (in the setup block).

nw:load-graphml "network_test.gml"

I receive the following error message "Extension exception: Unable to read Graph from document - the document could be empty error while observer running NW:LOAD-GRAPHML"

The document is not empty but maybe I did something wrong. What can I do? The GML files generated from Python look different from GML generated from Netlogo, which seem to record also turtles variables while Python does not. Could that be the source of the problem?

Thank you very much in advance for your kind help. Best, Aymeric

LaCuneta commented 5 years ago

@aymericvie It's very common to need to do some data manipulation to get things imported correctly, see this old answer as an example. However the error you posted doesn't appear to be that sort of issue. Can you attach or link to the file you were trying to load?

Edit to add: Did you try nw:load as well (or nw:load-gml)? Did it give the same error?

aymericvie commented 5 years ago

Thank you for your answer. Thanks for the information, I am quite new to importing networks in Netlogo. My problem probably indeed comes from compatibility of how the GML files are encoded.

Please find attached (in .txt to attach it but it is a gml file) the file I'm trying to import. alpha_0.00.txt

The problem occurs with nw:load-gml. Trying nw:load, I receive a different (yellow) error asking me to add 3 inputs: a string, a turtle agentset, a link agentset and a command block (optional).

Thank you very much. Best, Aymeric

LaCuneta commented 5 years ago

Thanks for sending the file! I took a look and it loaded for me. All I had to do was 1) rename it to alpha_0.00.gml and 2) make sure the file was in the same folder that I saved my test model to. Then when I used nw:load along with a default turtle breed and link breed (per the docs), it loaded up the data just fine:

extensions [ nw ]

to load
  clear-all
  nw:load "alpha_0.00.gml" turtles links
  repeat 500 [ layout ]
end

to layout
  let factor sqrt count turtles
  if factor = 0 [ set factor 1 ]
  layout-spring turtles links (1 / factor) (14 / factor) (1.5 / factor)
end

I took the layout code from the NW General Examples model from the Models Library, which has more ways to handle layout if you're interested (among other nw-related things).

Since things look to be working with the extension itself, I'm going to close this issue, but feel free to leave a comment if you need more assistance. Or the NetLogo users mailing list is also a good place to ask questions.

aymericvie commented 5 years ago

Thank you so much!