JuliaDynamics/Agents.jl

Can the open street map graph be altered during the simulation?

Closed this issue · 8 comments

The underlying graph can be altered using [`add_vertex!`](@ref) and [`rem_vertex!`](@ref).

It is not clear from this docstring whether the graph can be changed during the simulation. At least if it is a SimpleGraph, I would think that it can't, because the indices are not persistent.

mmh, I think it can be done, rem_vertex! and add_vertex! are specialized for GraphSpace and they work also on a SimpleGraph

But if you have a way to make the docstring clearer, go for it!

The node-to-index and index-to-node mappings in OSMGraph will be broken after removing vertices, since a SimpleGraph will always have indices 1:n. Or am I missing something?

I think that rem_vertex! (and add_vertex!) are only implemented for a GraphSpace, not for a OpenStreetMapSpace, which means that even if OSMGraph supports mutation, it can break how OpenStreetMapSpace works. But this seems it is a feature it can be added if OSMGraph supports mutation.

Ah yes, I got confused between the two spaces. It seems to be true that removing nodes from the GraphSpace is safe. For the OSM space it would be more involved, and I'd be worried to rely on too much internal stuff.

As far as I can tell @simsurace you need to open an issue at OpenStreetMapX.jl (the backend package) to implement an API for mutation. From our side even if we offer something it would be clunky, unsafe, and unmaintainable.

I think you meant LightOSM.jl, right?
In any case, this is what I thought as well, this would belong to the backend for sure. Just wanted to be sure I wasn‘t missing anything.

Sorry, yes LightOSM!