QuikGraph icon indicating copy to clipboard operation
QuikGraph copied to clipboard

[BUG] Multigraph bug?

Open johna1203 opened this issue 2 years ago • 1 comments

Describe the bug

I am trying to reproduce this strategy from the article below. https://anilpai.medium.com/currency-arbitrage-using-bellman-ford-algorithm-8938dcea56ea

Then I generated the following grap test

var tryGetPath = graph.ShortestPathsBellmanFord(e => e.Weight, "USD", out var hasNegativeCycle);
if (hasNegativeCycle) {
  Console.WriteLine("IS NEGATIVE");
}

if (tryGetPath("PLN", out var edges)) {
  Console.WriteLine($"PATH {string.Join("-->", edges.Select(e => e.Source).ToList())}");
}

but I have a problem, it is that there is an infinite loop in the following line. (EdgeExtensions.cs:265) You can see that it stays between USD <--> MXN and never leaves the while. quickGraph

I tried to fix it, but I don't know where the error.... is

If you need the source code, let me know and I'll post it here.

Thank you.

johna1203 avatar Mar 21 '22 18:03 johna1203