-
Notifications
You must be signed in to change notification settings - Fork 430
Closed
Description
Hi guys, appreciate if you have any idea how to implement this:
In the source code of bellman_ford.rs -> fn find_negative_cycle, I want to adjust two parts (of course I copied it out to my own crate):
- If the sum value is less than -0.1 (rather than 0), treat it as a negative cycle
I found the below source code, want to change the IF condition, idea is to change it to "if distance[ix(i)] + w + 0.1 < distance[ix(j)]", but the compiling error doesn't allow me to add f64 to FloatMeasure, how can I achieve it?
// Step 2: Check for negative weight cycle
'outer: for i in g.node_identifiers() {
for edge in g.edges(i) {
let j = edge.target();
let w = *edge.weight();
if distance[ix(i)] + w < distance[ix(j)] {
// Step 3: negative cycle found
- Although source node is passed into this function, but in some case, it will return the negative cycle that doesn't contain the source node. How to avoid that?
Thank you so much even you just provide some thoughts.
Metadata
Metadata
Assignees
Labels
No labels