From c54a16e8c0bf721c0feb88f5a4cd26168181ee4f Mon Sep 17 00:00:00 2001 From: himanshu342 <43965914+himanshu342@users.noreply.github.com> Date: Thu, 8 Oct 2020 19:28:59 +0530 Subject: [PATCH] Create floydWarshal Hackoctober --- floydWarshal | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 floydWarshal diff --git a/floydWarshal b/floydWarshal new file mode 100644 index 0000000..3aacbcb --- /dev/null +++ b/floydWarshal @@ -0,0 +1,36 @@ +#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