Q:

What is the best way to represent infinity in Solidity?

Solidity does not natively support infinity, so how would I represent infinity as a variable in Solidity? For example, if I wanted to write an implementation of Dijkstra's algorithm in Solidity it would need infinity.

A:

One possible way is to set a MAX_VALUE in your code, which is practically large enough so it will never be reached.
Or if all the distances are positive, you can use a negative number to represent an infinite value.

