Skip to content

Commit

Permalink
Update graph.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Sep 6, 2024
1 parent 3be05e7 commit 6d373a4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/spaces/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ random_position(model::ABM{<:GraphSpace}) = rand(abmrng(model), 1:nv(model))
function remove_agent_from_space!(agent::AbstractAgent, model::ABM{<:GraphSpace})
agentpos = agent.pos
ids = ids_in_position(agentpos, model)
deleteat!(ids, findfirst(a -> a == agent.id, ids))
return model
agentid = findfirst(a -> a == agent.id, ids)
isnothing(agentid) && error(lazy"Tried to remove $(agent) from the space, but that agent is not on the space")
deleteat!(ids, agentid)
return agent
end

function add_agent_to_space!(agent::AbstractAgent, model::ABM{<:GraphSpace})
Expand Down

0 comments on commit 6d373a4

Please sign in to comment.