I made weight directed graph, just like this
6
0 3 4 INFINITY INFINITY INFINITY
INFINITY 0 INFINITY 7 INFINITY INFINITY
INFINITY 3 0 5 11 INFINITY
INFINITY INFINITY INFINITY 0 6 3
INFINITY INFINITY INFINITY INFINITY 0 4
INFINITY INFINITY INFINITY INFINITY INFINITY 0
at first, I used some integer value to express infinity like 99 or 20000.
but when I find it is wrong, v5 -> v4 must be express infinity but some integer value is expressed.
ex : Shortest Path from v2 to v3 : v2 v3 (length : 200000)
is there any infinity value for integer?
friend of mine says ~(1<<31) but it doesn’t work
Unlike floating-point types, integer types don’t have a standard value for infinity. If you have to have one, you’ll have to pick a value yourself (e.g.
INT_MAX) and correctly handle it throughout your code. Note that if you do this, you can use the special value in assignments and comparisons, but not in arithmetic expressions.