mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-14 17:32:35 +08:00
Formatted with Google Java Formatter
This commit is contained in:
@ -48,7 +48,7 @@ start vertex, end vertes and weights. Vertices should be labelled with a number
|
||||
|
||||
public void
|
||||
go() // Interactive run for understanding the class first time. Assumes source vertex is 0 and
|
||||
// shows distaance to all vertices
|
||||
// shows distaance to all vertices
|
||||
{
|
||||
Scanner sc = new Scanner(System.in); // Grab scanner object for user input
|
||||
int i, v, e, u, ve, w, j, neg = 0;
|
||||
@ -66,7 +66,7 @@ start vertex, end vertes and weights. Vertices should be labelled with a number
|
||||
int dist[] =
|
||||
new int
|
||||
[v]; // Distance array for holding the finalized shortest path distance between source
|
||||
// and all vertices
|
||||
// and all vertices
|
||||
int p[] = new int[v]; // Parent array for holding the paths
|
||||
for (i = 0; i < v; i++) dist[i] = Integer.MAX_VALUE; // Initializing distance values
|
||||
dist[0] = 0;
|
||||
@ -115,7 +115,7 @@ start vertex, end vertes and weights. Vertices should be labelled with a number
|
||||
double dist[] =
|
||||
new double
|
||||
[v]; // Distance array for holding the finalized shortest path distance between source
|
||||
// and all vertices
|
||||
// and all vertices
|
||||
int p[] = new int[v]; // Parent array for holding the paths
|
||||
for (i = 0; i < v; i++) dist[i] = Integer.MAX_VALUE; // Initializing distance values
|
||||
dist[source] = 0;
|
||||
|
@ -13,7 +13,7 @@ public class FloydWarshall {
|
||||
new int[numberofvertices + 1]
|
||||
[numberofvertices
|
||||
+ 1]; // stores the value of distance from all the possible path form the source
|
||||
// vertex to destination vertex
|
||||
// vertex to destination vertex
|
||||
Arrays.fill(DistanceMatrix, 0);
|
||||
this.numberofvertices = numberofvertices;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package DataStructures.Heaps;
|
||||
|
||||
|
||||
/**
|
||||
* Class for heap elements.<br>
|
||||
*
|
||||
|
@ -61,12 +61,12 @@ public class SinglyLinkedList {
|
||||
checkBounds(position, 0, size);
|
||||
Node newNode = new Node(data);
|
||||
if (head == null) {
|
||||
/* the list is empty */
|
||||
/* the list is empty */
|
||||
head = newNode;
|
||||
size++;
|
||||
return;
|
||||
} else if (position == 0) {
|
||||
/* insert at the head of the list */
|
||||
/* insert at the head of the list */
|
||||
newNode.next = head;
|
||||
head = newNode;
|
||||
size++;
|
||||
|
Reference in New Issue
Block a user