Skip to content

Commit

Permalink
Sort the todo_nodes (#897) (#898)
Browse files Browse the repository at this point in the history
(cherry picked from commit af4af62)

Co-authored-by: Edwin Navarro <[email protected]>
  • Loading branch information
mergify[bot] and enavarro51 authored Jun 9, 2023
1 parent 629d04e commit da5fd17
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rustworkx-core/src/token_swapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use petgraph::visit::{
};
use petgraph::Directed;
use petgraph::Direction::{Incoming, Outgoing};
use rayon::prelude::*;
use rayon_cond::CondIterator;

use crate::connectivity::find_cycle;
Expand Down Expand Up @@ -127,10 +128,11 @@ where
.collect();

// todo_nodes are all the mapping entries where left != right
let todo_nodes: Vec<NodeIndex> = tokens
let mut todo_nodes: Vec<NodeIndex> = tokens
.iter()
.filter_map(|(node, dest)| if node != dest { Some(*node) } else { None })
.collect();
todo_nodes.par_sort();

// Add initial edges to the digraph/sub_digraph
for node in self.graph.node_identifiers() {
Expand Down

0 comments on commit da5fd17

Please sign in to comment.