mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 06:23:08 +08:00
style: enable ParameterName
in CheckStyle. (#5196)
* Enabled: ParameterName in CheckStyle. * Refactored to fix bug caused by selfAssignment of variables in VectorCrossproduct class
This commit is contained in:

committed by
GitHub

parent
2568b96784
commit
c42b1c940c
@ -18,14 +18,14 @@ public final class BipartiteGrapfDFS {
|
||||
private BipartiteGrapfDFS() {
|
||||
}
|
||||
|
||||
private static boolean bipartite(int V, ArrayList<ArrayList<Integer>> adj, int[] color, int node) {
|
||||
private static boolean bipartite(int v, ArrayList<ArrayList<Integer>> adj, int[] color, int node) {
|
||||
if (color[node] == -1) {
|
||||
color[node] = 1;
|
||||
}
|
||||
for (Integer it : adj.get(node)) {
|
||||
if (color[it] == -1) {
|
||||
color[it] = 1 - color[node];
|
||||
if (!bipartite(V, adj, color, it)) {
|
||||
if (!bipartite(v, adj, color, it)) {
|
||||
return false;
|
||||
}
|
||||
} else if (color[it] == color[node]) {
|
||||
@ -35,14 +35,14 @@ public final class BipartiteGrapfDFS {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isBipartite(int V, ArrayList<ArrayList<Integer>> adj) {
|
||||
public static boolean isBipartite(int v, ArrayList<ArrayList<Integer>> adj) {
|
||||
// Code here
|
||||
int[] color = new int[V + 1];
|
||||
int[] color = new int[v + 1];
|
||||
Arrays.fill(color, -1);
|
||||
|
||||
for (int i = 0; i < V; i++) {
|
||||
for (int i = 0; i < v; i++) {
|
||||
if (color[i] == -1) {
|
||||
if (!bipartite(V, adj, color, i)) {
|
||||
if (!bipartite(v, adj, color, i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ public class FloydWarshall {
|
||||
this.numberofvertices = numberofvertices;
|
||||
}
|
||||
|
||||
public void floydwarshall(int[][] AdjacencyMatrix) { // calculates all the distances from source to destination vertex
|
||||
public void floydwarshall(int[][] adjacencyMatrix) { // calculates all the distances from source to destination vertex
|
||||
for (int source = 1; source <= numberofvertices; source++) {
|
||||
for (int destination = 1; destination <= numberofvertices; destination++) {
|
||||
distanceMatrix[source][destination] = AdjacencyMatrix[source][destination];
|
||||
distanceMatrix[source][destination] = adjacencyMatrix[source][destination];
|
||||
}
|
||||
}
|
||||
for (int intermediate = 1; intermediate <= numberofvertices; intermediate++) {
|
||||
|
@ -60,7 +60,7 @@ public class TarjansAlgorithm {
|
||||
|
||||
private List<List<Integer>> sccList = new ArrayList<List<Integer>>();
|
||||
|
||||
public List<List<Integer>> stronglyConnectedComponents(int V, List<List<Integer>> graph) {
|
||||
public List<List<Integer>> stronglyConnectedComponents(int v, List<List<Integer>> graph) {
|
||||
|
||||
// Initially all vertices as unvisited, insertion and low time are undefined
|
||||
|
||||
@ -68,20 +68,20 @@ public class TarjansAlgorithm {
|
||||
|
||||
// lowTime: indicates the earliest visited vertex (the vertex with minimum insertion time)
|
||||
// that can be reached from a subtree rooted with a particular node.
|
||||
int[] lowTime = new int[V];
|
||||
int[] insertionTime = new int[V];
|
||||
for (int i = 0; i < V; i++) {
|
||||
int[] lowTime = new int[v];
|
||||
int[] insertionTime = new int[v];
|
||||
for (int i = 0; i < v; i++) {
|
||||
insertionTime[i] = -1;
|
||||
lowTime[i] = -1;
|
||||
}
|
||||
|
||||
// To check if element is present in stack
|
||||
boolean[] isInStack = new boolean[V];
|
||||
boolean[] isInStack = new boolean[v];
|
||||
|
||||
// Store nodes during DFS
|
||||
Stack<Integer> st = new Stack<Integer>();
|
||||
|
||||
for (int i = 0; i < V; i++) {
|
||||
for (int i = 0; i < v; i++) {
|
||||
if (insertionTime[i] == -1) stronglyConnCompsUtil(i, lowTime, insertionTime, isInStack, st, graph);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user