Click or drag to resize
Arbitrage Class

The Arbitrage class provides a client that finds an arbitrage opportunity in a currency exchange table by constructing a complete-digraph representation of the exchange table and then finding a negative cycle in the digraph.

This implementation uses the Bellman-Ford algorithm to find a negative cycle in the complete digraph. The running time is proportional to V3 in the worst case, where V is the number of currencies.

Inheritance Hierarchy
SystemObject
  Algs4NetArbitrage

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class Arbitrage

The Arbitrage type exposes the following members.

Methods
  NameDescription
Public methodStatic memberMainTest
Reads the currency exchange table from standard input and prints an arbitrage opportunity to standard output (if one exists).
Top
Remarks

For additional documentation, see Section 4.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class Arbitrage implementation by the respective authors.

See Also