mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 06:23:08 +08:00
style: enable MultipleVariableDeclarations
in checkstyle (#5175)
Co-authored-by: vaibhav <vaibhav.waghmare@techprescient.com>
This commit is contained in:
@ -11,7 +11,8 @@ class BellmanFord /*
|
||||
*/
|
||||
{
|
||||
|
||||
int vertex, edge;
|
||||
int vertex;
|
||||
int edge;
|
||||
private Edge[] edges;
|
||||
private int index = 0;
|
||||
|
||||
@ -23,7 +24,8 @@ class BellmanFord /*
|
||||
|
||||
class Edge {
|
||||
|
||||
int u, v;
|
||||
int u;
|
||||
int v;
|
||||
int w;
|
||||
|
||||
/**
|
||||
@ -58,7 +60,14 @@ class BellmanFord /*
|
||||
public void go() { // shows distance to all vertices // Interactive run for understanding the
|
||||
try ( // class first time. Assumes source vertex is 0 and
|
||||
Scanner sc = new Scanner(System.in)) {
|
||||
int i, v, e, u, ve, w, j, neg = 0;
|
||||
int i;
|
||||
int v;
|
||||
int e;
|
||||
int u;
|
||||
int ve;
|
||||
int w;
|
||||
int j;
|
||||
int neg = 0;
|
||||
System.out.println("Enter no. of vertices and edges please");
|
||||
v = sc.nextInt();
|
||||
e = sc.nextInt();
|
||||
@ -120,7 +129,11 @@ class BellmanFord /*
|
||||
Edge[] arr) { // be created by using addEdge() method and passed by calling getEdgeArray()
|
||||
// method // Just shows results of computation, if graph is passed to it. The
|
||||
// graph should
|
||||
int i, j, v = vertex, e = edge, neg = 0;
|
||||
int i;
|
||||
int j;
|
||||
int v = vertex;
|
||||
int e = edge;
|
||||
int neg = 0;
|
||||
double[] dist = new double[v]; // Distance array for holding the finalized shortest path
|
||||
// distance between source
|
||||
// and all vertices
|
||||
|
@ -22,7 +22,8 @@ class Graph<E extends Comparable<E>> {
|
||||
|
||||
class Edge {
|
||||
|
||||
Node startNode, endNode;
|
||||
Node startNode;
|
||||
Node endNode;
|
||||
|
||||
Edge(Node startNode, Node endNode) {
|
||||
this.startNode = startNode;
|
||||
@ -46,7 +47,8 @@ class Graph<E extends Comparable<E>> {
|
||||
* @param endNode the ending Node from the edge
|
||||
*/
|
||||
public void addEdge(E startNode, E endNode) {
|
||||
Node start = null, end = null;
|
||||
Node start = null;
|
||||
Node end = null;
|
||||
for (Node node : nodeList) {
|
||||
if (startNode.compareTo(node.name) == 0) {
|
||||
start = node;
|
||||
|
@ -5,7 +5,8 @@ import java.util.Scanner;
|
||||
|
||||
class Cycle {
|
||||
|
||||
private int nodes, edges;
|
||||
private final int nodes;
|
||||
private final int edges;
|
||||
private int[][] adjacencyMatrix;
|
||||
private boolean[] visited;
|
||||
ArrayList<ArrayList<Integer>> cycles = new ArrayList<ArrayList<Integer>>();
|
||||
@ -27,7 +28,8 @@ class Cycle {
|
||||
System.out.println("Enter the details of each edges <Start Node> <End Node>");
|
||||
|
||||
for (int i = 0; i < edges; i++) {
|
||||
int start, end;
|
||||
int start;
|
||||
int end;
|
||||
start = in.nextInt();
|
||||
end = in.nextInt();
|
||||
adjacencyMatrix[start][end] = 1;
|
||||
|
@ -9,7 +9,8 @@ class dijkstras {
|
||||
int k = 9;
|
||||
|
||||
int minDist(int[] dist, Boolean[] Set) {
|
||||
int min = Integer.MAX_VALUE, min_index = -1;
|
||||
int min = Integer.MAX_VALUE;
|
||||
int min_index = -1;
|
||||
|
||||
for (int r = 0; r < k; r++) {
|
||||
if (!Set[r] && dist[r] <= min) {
|
||||
|
@ -75,7 +75,8 @@ class AdjacencyListGraph<E extends Comparable<E>> {
|
||||
* already did
|
||||
*/
|
||||
public boolean addEdge(E from, E to) {
|
||||
Vertex fromV = null, toV = null;
|
||||
Vertex fromV = null;
|
||||
Vertex toV = null;
|
||||
for (Vertex v : vertices) {
|
||||
if (from.compareTo(v.data) == 0) { // see if from vertex already exists
|
||||
fromV = v;
|
||||
|
@ -8,7 +8,8 @@ package com.thealgorithms.datastructures.graphs;
|
||||
*/
|
||||
public class HamiltonianCycle {
|
||||
|
||||
private int V, pathCount;
|
||||
private int V;
|
||||
private int pathCount;
|
||||
private int[] cycle;
|
||||
private int[][] graph;
|
||||
|
||||
|
@ -14,7 +14,8 @@ class PrimMST {
|
||||
// value, from the set of vertices not yet included in MST
|
||||
int minKey(int[] key, Boolean[] mstSet) {
|
||||
// Initialize min value
|
||||
int min = Integer.MAX_VALUE, min_index = -1;
|
||||
int min = Integer.MAX_VALUE;
|
||||
int min_index = -1;
|
||||
|
||||
for (int v = 0; v < V; v++) {
|
||||
if (!mstSet[v] && key[v] < min) {
|
||||
|
Reference in New Issue
Block a user