Min-plus matrix multiplication implementation
In the tropical semiring, the "addition" operation is the minimum, and the "multiplication" operation is addition. 

If you want to adapt matrix multiplication to the tropical semiring, you literally need to replace every occurrence of $+$ with $\min$, and $*$ with $+$.

To this effect, look at the line:


  sum+= A[i][k]*B[k][j]


Let's rewrite it "properly", as:


  sum= sum+A[i][k]*B[k][j]


Then, in the tropical semiring, this becomes:


  sum= min(sum, A[i][k]+B[k][j])


And you're done.