From 01e95edfddb8dab82df67a0d5224a5c37c4d1eb7 Mon Sep 17 00:00:00 2001 From: Justus Adam Date: Fri, 6 Sep 2024 16:47:55 -0700 Subject: [PATCH] Reverse direction in shortest path --- crates/paralegal-policy/src/context.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/paralegal-policy/src/context.rs b/crates/paralegal-policy/src/context.rs index 18a286f9d6..d836c4beda 100644 --- a/crates/paralegal-policy/src/context.rs +++ b/crates/paralegal-policy/src/context.rs @@ -17,7 +17,7 @@ use paralegal_spdg::{ use anyhow::{anyhow, bail, Result}; use itertools::{Either, Itertools}; use petgraph::prelude::Bfs; -use petgraph::visit::{EdgeFiltered, EdgeRef, IntoNeighborsDirected, Topo, Walker}; +use petgraph::visit::{EdgeFiltered, EdgeRef, IntoNeighborsDirected, Reversed, Topo, Walker}; use petgraph::Direction::Outgoing; use petgraph::{Direction, Incoming}; @@ -923,7 +923,8 @@ impl NodeExt for GlobalNode { &ctx.desc.controllers[&self.controller_id()] }; let mut ancestors = HashMap::new(); - let fg = edge_selection.filter_graph(&g.graph); + let filtered = edge_selection.filter_graph(&g.graph); + let fg = Reversed(&filtered); let mut found = false; 'outer: for this in petgraph::visit::Bfs::new(&fg, self.local_node()).iter(&fg) { for next in fg.neighbors_directed(this, Outgoing) {