Asking for much needed help to import a temporal multiplex multilayer graphml file into Netlogo and create an appropriate model setup

Hello, I am having a heck of a time trying to import a graphml file into netlogo and set up the model the way I need it. I’ve gone through all the network tutorials and I think the base problem is I don’t understand how to go from the graphml file with edge and node attributes to the netlogo vocabulary.
I made the graphml file in python with networkx-temporal from an edgelist and node list. I can get the nodes in as turtles, although they will be stationary and not move. But each edge is actually a vehicle that is moving, and each vehicle has multiple edges between the nodes over time. These are what is actually moving and what I need to follow in the model.

I am trying to import it into NetLogo and am having a heck of a time. I am new to NetLogo- trying to use it for my thesis.
The two layers of edges are the two veh_types edge attribute.
Each edgeID attribute is a different vehicle that i need to track along the edges of the network.
The end_time attribute is the discrete time of the temporal graph.

My thought was to import the nodes as one breed of turtle (that will stay stationary), and import the edgeID attribute (the vehicle name) as another breed of turtle since these will be moving. then use all the edges as ways the vehicles can move across. but the edgeID is an edge attribute in my edgelist.

I have tried AI help, read all the nw:extension documentation, roman-road network tutorial, looked through all the github models and examples, etc. I am all out of ideas.

the following code is the only one that has given me a network in the environment. The problem is that all the edges are just links and all the nodes are the turtles, but they aren’t supposed to move. I need the vehicles to move along the edges.

I’ve tried something like this and different varieties

I’ve also tried playing with this code to try and create the nodes separately, but to no avail:

The newest code i’ve tried as of last night is:

Any direction or help would be greatly appreciated. thank you!

Hi @pandora,

Correct me if I misunderstood, but it seems like the main problem you’re having is that edges in the GraphML file are imported into NetLogo as links instead of turtles. I don’t think there’s a way to directly import edges as turtles, however you can convert the links into turtles after importing the graph. Here’s one way you could approach this:

Hopefully this helps! Let me know if that doesn’t solve the problem, or if you have any other questions.

Isaac B.

Hi Isaac,

Thank you. Your help is very much appreciated.

I believe you have it correct. each edge in my network is a movement of the vehicle between nodes. I want to track those vehicles as an epi model for disease tracking. therefore, those vehicles, can only move on the edges that are designated for them. I’ve updated the model based on another feedback about what breeds really are from a different post. And added your code. I think what your code is saying is- ask each link and find out it’s source , then create one vehicle at that node. the kill that link. Is this correct? I actually don’t think I want to kill the link- bc i need to know the target node and have that vehicle move to that target next. so it needs to follow it’s edges. Does that make sense?
Also, when I load this, the nodes are not placed at the lat and long- just all bunched up. Do you have any advice about this.

Hi @pandora,

You can certainly leave the links in place, but if you would prefer, you could also add vehicles-own variables to keep track of end1 and end2 of the original link after it dies.

Regarding the node positions: it looks like you’re trying to set a transformation with the gis extension, but this only affects data imported directly with the gis extension, it’s not a global transformation for world coordinates. What I would recommend instead is to calculate the bounds of the imported data (eg. with min [ lat ] of nodes, etc.) and then manually scale the latitudes and longitudes before calling setxy. Or if you already know what the bounds will be, then you don’t need to do anything with min and max, and you can just scale the positions directly.

Let me know if any of this doesn’t make sense, or if you need help implementing that behavior!

Isaac B.

Hello @ERSUCC

That gave me an idea. Instead of worrying about edges at all, why not just import the vehicles as turtles and use the source, target nodes and just have them move. Does it have to follow an edge??

I also tried importing everything from a csv (vehicle list, edge list and node list). I got something this way, though much longer to load with over 430,000 ‘edges’ and 1900 vehicles.

FYI- the gis worked. I was able to import and graph the nodes by looping through the rows of the node list and using the gis coordinates with this code. I’m just having trouble with the vehicles now, when i try to assign the vehicle x/y coord to the first node it starts on. I might start a new post unless you don’t mind me following up with that here?

thank you for helping me through this, your insights really helped.

Hi @pandora,

It’s good to hear that you’re making progress! We can continue in this issue or in a separate issue, it doesn’t really make a difference as long as it’s related.

I’m not sure what you mean by “just import the vehicles as turtles”. If you’re able to edit your GraphML file to represent the vehicles as nodes, then it definitely would make more sense to create them as turtles from the start. But if the vehicles will always be represented as edges in the GraphML file, I don’t think you will be able to import them as turtles, because the nw extension assumes that nodes correspond to turtles and edges correspond to links.

Could you be a bit more specific about the issue you’re having with gis? When you try to assign the x/y coordinate, what exactly happens that is unexpected?

Isaac B.

I appreciate it. Here is my output so far with code. I went back to the data and made 3 csv files, one for nodes, one for edges, and one for vehicles. And I uploaded each csv so that the nodes and vehicles were turtles. I had the edges there too, but not sure if I really need them or not since the vehicles will be moving between the nodes anyway with the same information that is in the edge list. The problem right now, is the code part that says ;fin the corresponding source node and place vehicle there. I’m getting the runtime error : NODES breed does not own variable START.

I’m trying to start the vehicles on the starting node that it starts on from the csv file.
Ex:

vehicle name Start_node end_node time (of that movement)

So I’m trying to find the node that equals the start_node number to place the vehicle there at that time moment. - I haven’t gotten the ticks to work yet-

then each tick, the model should check the next time in the data and create that vehicle movement between the nodes.
this will eventually be an epi model where the vehicles will be the transmission between the nodes, etc.

Oh, and I have tried to use ‘read-from-string’ command, but made sure that the data is numeric, etc.

Hi @pandora,

The with primitive doesn’t look in the parent agent context to find variables, so you’ll have to store the value of start in a local variable for it to be found. For example:

You can also use myself to explicitly reference the parent context, for example:

Isaac B.

1 Like

Now that makes so much more sense. I was wondering why there were so many local variables made in the code snippets I was looking at. And that just worked perfectly. Now i’ll get the ticks working and hopefully move on to movement. I don’t even know where to start to thank you. I very much appreciate your help and explanation.

Good luck, and feel free to open a new issue if you have any more problems!