Skip to content

Add automatic linter #4214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
acbin committed Jun 9, 2023
commit 727bfa688c6370d347cc9b23c848a9cbae3a3850
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.thealgorithms.datastructures.graphs;

/**
* Java program for Hamiltonian Cycle (https://en.wikipedia.org/wiki/Hamiltonian_path)
* Java program for Hamiltonian Cycle
* (https://en.wikipedia.org/wiki/Hamiltonian_path)
*
* @author Akshay Dubey (https://github.com/itsAkshayDubey)
*/
public class HamiltonianCycle {
Expand All @@ -12,10 +14,11 @@ public class HamiltonianCycle {

/**
* Find hamiltonian cycle for given graph G(V,E)
*
* @param graph Adjacency matrix of a graph G(V, E)
* for which hamiltonian path is to be found
* for which hamiltonian path is to be found
* @return Array containing hamiltonian cycle
* else returns 1D array with value -1.
* else returns 1D array with value -1.
*/
public int[] findHamiltonianCycle(int[][] graph) {
this.V = graph.length;
Expand Down Expand Up @@ -44,12 +47,12 @@ public int[] findHamiltonianCycle(int[][] graph) {
/**
* function to find paths recursively
* Find paths recursively from given vertex
*
* @param vertex Vertex from which path is to be found
* @returns true if path is found false otherwise
*/
public boolean isPathFound(int vertex) {
boolean isLastVertexConnectedToStart
= this.graph[vertex][0] == 1 && this.pathCount == this.V;
boolean isLastVertexConnectedToStart = this.graph[vertex][0] == 1 && this.pathCount == this.V;
if (isLastVertexConnectedToStart) {
return true;
}
Expand All @@ -69,7 +72,7 @@ public boolean isPathFound(int vertex) {
this.graph[vertex][v] = 0;
this.graph[v][vertex] = 0;

/** if vertex not already selected solve recursively **/
/** if vertex not already selected solve recursively **/
if (!isPresent(v)) {
return isPathFound(v);
}
Expand All @@ -88,6 +91,7 @@ public boolean isPathFound(int vertex) {
/**
* function to check if path is already selected
* Check if path is already selected
*
* @param vertex Starting vertex
*/
public boolean isPresent(int vertex) {
Expand Down