Skip to content

Commit

Permalink
Fix non-deterministic independent cycles.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Jan 10, 2024
1 parent 4f5a476 commit f8a28bc
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ impl SdGraph {
while let Some(mut scc) = components.pop() {
let mut best_cycle = None;
let mut best_cycle_len = usize::MAX;
for x in &scc {
// Not particularly efficient, but keeps this whole thing deterministic.
let mut scc_iter: Vec<VariableId> = scc.iter().cloned().collect();
scc_iter.sort();
for x in &scc_iter {
if let Some(cycle) = self.shortest_cycle(&scc, *x, best_cycle_len) {
if cycle.len() == 1 {
// Cycle of length one will always win, no need to check further.
Expand Down

0 comments on commit f8a28bc

Please sign in to comment.