Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Tuple<int[,], int[,]> findPath(int[,] matrix, int factoryCount){
- int[,] dist = new int[factoryCount, factoryCount];
- int[,] next = new int[factoryCount, factoryCount];
- for(int x = 0; x < factoryCount; x++){
- for(int y = 0; y < factoryCount; y++){
- dist[x,y] = matrix[x,y];
- next[x,y] = y;
- }
- }
- for(int z = 0; z < factoryCount; z++){
- dist[z,z] = 0;
- next[z,z] = z;
- }
- for(int k = 0; k < factoryCount; k++){
- for(int i = 0; i < factoryCount; i++){
- for(int j = 0; j < factoryCount; j++){
- if (dist[i, j] > dist[i, k] + dist[k, j]){
- dist[i, j] = dist[i, k] + dist[k, j];
- next[i, j] = next[i, k];
- }
- }
- }
- }
- return new Tuple<int[,], int[,]>(dist, next);
- }
Advertisement
Add Comment
Please, Sign In to add comment