Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Algo] floyd warshall algorithm for finding all pair shortest path in a connected graph [CPP] #287

Closed
wants to merge 10 commits into from

Conversation

vivekcrux
Copy link

@vivekcrux vivekcrux commented Oct 5, 2018

…ected graph

For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!

Fixes #338

By submitting this pull request I confirm I've read and complied with the
below declarations.

  • I have read the Contribution guidelines and I am confident that my PR reflects them.
  • I have followed the commit guidelines for this project.
  • My code follows the standard code structure.
  • This pull request has a descriptive title. For example, {Tag}: Add {Algorithm/DS name} [{Language}], not Update README.md or Added new code.
  • This pull request will be closed if I fail to update it even once in a continuous time span of 7 days.
  • This pull request shall only be reviewed and merged once all the checks passes. No maintainer or supporter shall be obliged to review it before this condition is met.
  • I have mentioned the issue number correctly (with hyperlink) in this pull request description.

After you submit your pull request, DO NOT click the 'Update Branch' button.

}


for(k=1;k<=n;k++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.cpp.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpux02frhq/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
+++ b/tmp/tmpux02frhq/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
@@ -27,7 +27,7 @@
 	}
 
 
-	for(k=1;k<=n;k++)					
+	for(k=1;k<=n;k++)
 	{
 		for(int u=1;u<=n;u++)
 		{

for(int v=1;v<=n;v++)
{
//Shortest distance between (i,j) using atmost k edges
graph[u][v] = min(graph[u][v],graph[u][k]+graph[k][v]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.cpp.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpux02frhq/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
+++ b/tmp/tmpux02frhq/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
@@ -34,7 +34,7 @@
 			for(int v=1;v<=n;v++)
 			{
 				//Shortest distance between (i,j) using atmost k edges
-				graph[u][v] = min(graph[u][v],graph[u][k]+graph[k][v]);	
+				graph[u][v] = min(graph[u][v],graph[u][k]+graph[k][v]);
 			}
 		}
 	}


/*
Input:-
First line contain two space separated integer n and m
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.cpp.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpux02frhq/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
+++ b/tmp/tmpux02frhq/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
@@ -54,7 +54,7 @@
 
 /*
 Input:-
-First line contain two space separated integer n and m 
+First line contain two space separated integer n and m
 where n is the number of vertices and m is the number 
 of edges.Next m lines contains three space seprated integers
 u, v and w which represents that there is an edge between u and v

/*
Input:-
First line contain two space separated integer n and m
where n is the number of vertices and m is the number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.cpp.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpux02frhq/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
+++ b/tmp/tmpux02frhq/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
@@ -55,7 +55,7 @@
 /*
 Input:-
 First line contain two space separated integer n and m 
-where n is the number of vertices and m is the number 
+where n is the number of vertices and m is the number
 of edges.Next m lines contains three space seprated integers
 u, v and w which represents that there is an edge between u and v
 and weight of the edge is w

cout << endl;
return 0;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.cpp.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpphdb420x/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
+++ b/tmp/tmpphdb420x/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
@@ -28,7 +28,7 @@
 		for(int u = 1; u <= n; u++) {
 			for(int v = 1;v <= n; v++) {
 				//Shortest distance between (i,j) using atmost k edges
-				graph[u][v] = min(graph[u][v], graph[u][k] + graph[k][v]);	
+				graph[u][v] = min(graph[u][v], graph[u][k] + graph[k][v]);
 			}
 		}
 	}

@sangamcse
Copy link
Member

Comment on 732e3bb, file floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp, line 49.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.cpp.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpphdb420x/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
+++ b/tmp/tmpphdb420x/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
@@ -46,7 +46,7 @@
 
 /*
 Input:-
-First line contain two space separated integer n and m 
+First line contain two space separated integer n and m
 where n is the number of vertices and m is the number 
 of edges.Next m lines contains three space seprated integers
 u, v and w which represents that there is an edge between u and v

@sangamcse
Copy link
Member

Comment on 732e3bb, file floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp, line 50.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: all.cpp.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpphdb420x/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
+++ b/tmp/tmpphdb420x/floyd_warshall_algorithm/CPP/floyd-warshall algorithm.cpp
@@ -47,7 +47,7 @@
 /*
 Input:-
 First line contain two space separated integer n and m 
-where n is the number of vertices and m is the number 
+where n is the number of vertices and m is the number
 of edges.Next m lines contains three space seprated integers
 u, v and w which represents that there is an edge between u and v
 and weight of the edge is w

}
cout << endl;
}
cout << endl;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after ; [whitespace/semicolon] [3]

Origin: CPPLintBear, Section: all.cpplint.

cout << endl;
return 0;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Origin: CPPLintBear, Section: all.cpplint.

@@ -0,0 +1,65 @@
//Floyd-Warshall Algorithm: all pair shortest path
#include <iostream>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after ; [whitespace/semicolon] [3]

Origin: CPPLintBear, Section: all.cpplint.

graph[u][v] = min(graph[u][v], graph[u][k] + graph[k][v]);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after ; [whitespace/semicolon] [3]

Origin: CPPLintBear, Section: all.cpplint.

@vivekcrux vivekcrux changed the title floyd warshall algorithm for finding all pair shortest path in a conn… [Algo] floyd warshall algorithm for finding all pair shortest path in a connected graph [CPP] Oct 6, 2018
graph matrix size according to input number of vertices.
#define INF 999999999

int main() {
freopen("input.txt", "r", stdin);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Origin: CPPLintBear, Section: all.cpplint.

@sangamcse
Copy link
Member

Read the documentation before opening any PR

@sangamcse sangamcse closed this Oct 6, 2018
@sangamcse sangamcse added invalid This doesn't seem right and removed bug Something isn't working difficulty/low difficulty/medium hacktoberfest HACKTOBERFEST 2020 process/pending_review type/algo labels Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Algo] Add floyd warshall algorithm for finding all pair shortest path in a connected graph [CPP]
2 participants