INOI1402 - code isnt working

I have used the floyd warshall algorithm . I cant figure out whats wrong in the code. The output is a very large number

Code : CodeChef: Practical coding for everyone

I have made changes according to the undirected nature of graph ie graph[y][x]=p ; Still not working .