Skip to content

used to find the shorthest paths among all pairs of nodes in a graph, - #389

Closed
ayushnagar123 wants to merge 1 commit into
TheAlgorithms:masterfrom
ayushnagar123:patch-1
Closed

ayushnagar123 wants to merge 1 commit into
TheAlgorithms:masterfrom
ayushnagar123:patch-1

Conversation

@ayushnagar123

Copy link
Copy Markdown
Contributor

Floyd-Warshall algorithm is a procedure, which is used to find the shorthest (longest) paths among all pairs of nodes in a graph, which does not contain any cycles of negative lenght. The main advantage of Floyd-Warshall algorithm is its simplicity.

Floyd-Warshall algorithm is a procedure, which is used to find the shorthest (longest) paths among all pairs of nodes in a graph, which does not contain any cycles of negative lenght. The main advantage of Floyd-Warshall algorithm is its simplicity.

@christianbender christianbender left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good Work! I have some requests



public class FloydWarshall

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove unnecessary empty lines.


{

adjacency_matrix[source][destination] = scan.nextInt();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Spare the user for unnecessary inputs if the inputs will be overwrite.


{

private int distancematrix[][];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Naming conventions: Use camel case
For example distanceMatrix


{

adjacency_matrix[source][destination] = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please use camel case.


{

distancematrix = new int[numberofvertices + 1][numberofvertices + 1];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please initialize the array 'distancematrix' with zeros. for safety.


}


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Put in comments in your code. Makes the program readable for others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants