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-graphml not importing link-breed #189

Closed Joe-Wasserman closed 5 years ago

Joe-Wasserman commented 5 years ago

Using NetLogo 6.0.4, nw:load-graphml is not importing link-breed attributes from a graphml file saved from R. In addition to a straight import, I've also tried:

  1. changing the attribute id from "e_breed" to "breed" in the graphml file, and
  2. saving separate graphml files for each breed and then using nw:set-context before importing each.

Example graphml file:

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
         http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="v_name" for="node" attr.name="name" attr.type="string"/>
  <key id="e_breed" for="edge" attr.name="breed" attr.type="string"/>
  <graph id="G" edgedefault="undirected">
    <node id="n0">
      <data key="v_name">1</data>
    </node>
    <node id="n1">
      <data key="v_name">2</data>
    </node>
    <node id="n2">
      <data key="v_name">3</data>
    </node>
    <edge source="n1" target="n2">
      <data key="e_breed">ftf-tie</data>
    </edge>
    <edge source="n0" target="n3">
      <data key="e_breed">ftf-tie</data>
    </edge>
  </graph>
</graphml>

Example NetLogo import code:

extensions [ nw ]

undirected-link-breed [ ftf-ties ftf-tie ]
undirected-link-breed [ sns-ties sns-tie ]

to setup
  clear-all
  nw:load-graphml "test.graphml"
  repeat 30 [ layout-spring turtles links 0.2 5 1 ]
end

See also: https://stackoverflow.com/questions/54298799/importing-link-breed-in-netlogo-using-nwload-graphml

LaCuneta commented 5 years ago

Thanks for the report! The import expects the breed name to be the plural version, so in this case you can use ftf-ties or sns-ties. With that change your data should load with breeds as expected.

I'll make a note to update the docs and to also look into an update to take either the plural or singular name value when picking breeds, since it seems like it should be more forgiving.

Joe-Wasserman commented 5 years ago

Thank you, that works perfectly! I'm glad it was user error and not a true bug.