Skip to content
Snippets Groups Projects
Commit bcbb5547 authored by hagrid67's avatar hagrid67
Browse files

performance fix for agent_chains, reduce the calls to G.reverse()

parent 59832571
No related branches found
No related tags found
No related merge requests found
......@@ -74,20 +74,20 @@ class MotionCheck(object):
#print("Component:", oWCC)
Gwcc = self.G.subgraph(oWCC)
#lChain = list(nx.topological_sort(Gwcc))
#print("path: ", lChain)
# Find all the stops in this chain
svCompStops = svStops.intersection(Gwcc)
#print(svCompStops)
if len(svCompStops) > 0:
#print("component contains a stop")
# We need to traverse it in reverse - back up the movement edges
Gwcc_rev = Gwcc.reverse()
for vStop in svCompStops:
iter_stops = nx.algorithms.traversal.dfs_postorder_nodes(Gwcc.reverse(), vStop)
# Find all the agents stopped by vStop by following the (reversed) edges
# This traverses a tree - dfs = depth first seearch
iter_stops = nx.algorithms.traversal.dfs_postorder_nodes(Gwcc_rev, vStop)
lStops = list(iter_stops)
#print(vStop, "affected preds:", lStops)
svBlocked.update(lStops)
return svBlocked
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment