From eee49c9e986f359199b207b2546c88e3fbbefaea Mon Sep 17 00:00:00 2001 From: Ayushi C <67193440+AyushiChakrabarty@users.noreply.github.com> Date: Wed, 4 Nov 2020 11:09:15 +0530 Subject: [PATCH] Create Floyd Warshall --- Floyd Warshall | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Floyd Warshall diff --git a/Floyd Warshall b/Floyd Warshall new file mode 100644 index 0000000..7a6fe57 --- /dev/null +++ b/Floyd Warshall @@ -0,0 +1,41 @@ +#include +#include +#define NODE 7 +#define INF 999 +using namespace std; + +//Cost matrix of the graph +int costMat[NODE][NODE] = { + {0, 3, 6, INF, INF, INF, INF}, + {3, 0, 2, 1, INF, INF, INF}, + {6, 2, 0, 1, 4, 2, INF}, + {INF, 1, 1, 0, 2, INF, 4}, + {INF, INF, 4, 2, 0, 2, 1}, + {INF, INF, 2, INF, 2, 0, 1}, + {INF, INF, INF, 4, 1, 1, 0} +}; + +void floydWarshal() { + int cost[NODE][NODE]; //defind to store shortest distance from any node to any node + for(int i = 0; i