Let us create the graph shown in above diagram
int graph [ ] [ ] = new int [ ] [ ] { { 0 , 10 , 3 , 2 } , { INF , 0 , INF , 7 } , { INF , INF , 0 , 6 } , { INF , INF , INF , 0 } } ; ShortestPath t = new ShortestPath ( ) ; int u = 0 , v = 3 , k = 2 ; System . out . println ( " Weight ▁ of ▁ the ▁ shortest ▁ path ▁ is ▁ " + t . shortestPath ( graph , u , v , k ) ) ; } }