Remove unnecessary code (#4141)

This commit is contained in:
Saurabh Rahate
2023-04-03 20:05:59 +05:30
committed by GitHub
parent 805f09850c
commit ad72c28d91
64 changed files with 125 additions and 322 deletions

View File

@ -74,7 +74,7 @@ start vertex, end vertex and weights. Vertices should be labelled with a number
for (i = 0; i < v - 1; i++) {
for (j = 0; j < e; j++) {
if (
(int) dist[arr[j].u] != Integer.MAX_VALUE &&
dist[arr[j].u] != Integer.MAX_VALUE &&
dist[arr[j].v] > dist[arr[j].u] + arr[j].w
) {
dist[arr[j].v] = dist[arr[j].u] + arr[j].w; // Update
@ -85,7 +85,7 @@ start vertex, end vertex and weights. Vertices should be labelled with a number
// Final cycle for negative checking
for (j = 0; j < e; j++) {
if (
(int) dist[arr[j].u] != Integer.MAX_VALUE &&
dist[arr[j].u] != Integer.MAX_VALUE &&
dist[arr[j].v] > dist[arr[j].u] + arr[j].w
) {
neg = 1;

View File

@ -28,7 +28,7 @@ public class BipartiteGrapfDFS {
for (Integer it : adj.get(node)) {
if (color[it] == -1) {
color[it] = 1 - color[node];
if (bipartite(V, adj, color, it) == false) {
if (!bipartite(V, adj, color, it)) {
return false;
}
} else if (color[it] == color[node]) {

View File

@ -12,7 +12,7 @@ class dijkstras {
int min = Integer.MAX_VALUE, min_index = -1;
for (int r = 0; r < k; r++) {
if (Set[r] == false && dist[r] <= min) {
if (!Set[r] && dist[r] <= min) {
min = dist[r];
min_index = r;
}

View File

@ -154,11 +154,7 @@ class AdjacencyMatrixGraph {
* @return whether or not the vertex exists
*/
public boolean vertexDoesExist(int aVertex) {
if (aVertex >= 0 && aVertex < this.numberOfVertices()) {
return true;
} else {
return false;
}
return aVertex >= 0 && aVertex < this.numberOfVertices();
}
/**
@ -343,14 +339,14 @@ class AdjacencyMatrixGraph {
public String toString() {
String s = " ";
for (int i = 0; i < this.numberOfVertices(); i++) {
s = s + String.valueOf(i) + " ";
s = s + i + " ";
}
s = s + " \n";
for (int i = 0; i < this.numberOfVertices(); i++) {
s = s + String.valueOf(i) + " : ";
s = s + i + " : ";
for (int j = 0; j < this.numberOfVertices(); j++) {
s = s + String.valueOf(this._adjacency[i][j]) + " ";
s = s + this._adjacency[i][j] + " ";
}
s = s + "\n";
}

View File

@ -17,7 +17,7 @@ class PrimMST {
int min = Integer.MAX_VALUE, min_index = -1;
for (int v = 0; v < V; v++) {
if (mstSet[v] == false && key[v] < min) {
if (!mstSet[v] && key[v] < min) {
min = key[v];
min_index = v;
}
@ -80,7 +80,7 @@ class PrimMST {
{
if (
graph[u][v] != 0 &&
mstSet[v] == false &&
!mstSet[v] &&
graph[u][v] < key[v]
) {
parent[v] = u;

View File

@ -114,7 +114,7 @@ public class TarjansAlgorithm {
stronglyConnCompsUtil(n, lowTime, insertionTime, isInStack, st, graph);
//update lowTime for the current node comparing lowtime of adj node
lowTime[u] = Math.min(lowTime[u], lowTime[n]);
} else if (isInStack[n] == true) {
} else if (isInStack[n]) {
//If adj node is in stack, update low
lowTime[u] = Math.min(lowTime[u], insertionTime[n]);
}