Skip to content

style: enable InvalidJavadocPosition in checkstyle #5237

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 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

<!-- Checks for Javadoc comments. -->
<!-- See https://checkstyle.org/checks/javadoc/index.html -->
<!-- TODO <module name="InvalidJavadocPosition"/> -->
<module name="InvalidJavadocPosition"/>
<!-- TODO <module name="JavadocMethod"/> -->
<!-- TODO <module name="JavadocType"/> -->
<!-- TODO <module name="JavadocVariable"/> -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Author : Siddhant Swarup Mallick
* Github : https://github.com/siddhant2002
*/

/** Program description - To find all possible paths from source to destination*/

/**Wikipedia link -> https://en.wikipedia.org/wiki/Shortest_path_problem */
package com.thealgorithms.backtracking;

import java.util.ArrayList;
import java.util.List;

/**
* Program description - To find all possible paths from source to destination
* <a href="https://en.wikipedia.org/wiki/Shortest_path_problem">Wikipedia</a>
*
* @author <a href="https://github.com/siddhant2002">Siddhant Swarup Mallick</a>
*/
public class AllPathsFromSourceToTarget {

// No. of vertices in graph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/**
* Java program for Hamiltonian Cycle
* (https://en.wikipedia.org/wiki/Hamiltonian_path)
* <a href="https://en.wikipedia.org/wiki/Hamiltonian_path">wikipedia</a>
*
* @author Akshay Dubey (https://github.com/itsAkshayDubey)
* @author <a href="https://github.com/itsAkshayDubey">Akshay Dubey</a>
*/
public class HamiltonianCycle {

Expand Down Expand Up @@ -58,31 +58,31 @@ public boolean isPathFound(int vertex) {
return true;
}

/** all vertices selected but last vertex not linked to 0 **/
/* all vertices selected but last vertex not linked to 0 **/
if (this.pathCount == this.vertex) {
return false;
}

for (int v = 0; v < this.vertex; v++) {
/** if connected **/
/* if connected **/
if (this.graph[vertex][v] == 1) {
/** add to path **/
/* add to path **/
this.cycle[this.pathCount++] = v;

/** remove connection **/
/* remove connection **/
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);
}

/** restore connection **/
/* restore connection **/
this.graph[vertex][v] = 1;
this.graph[v][vertex] = 1;

/** remove path **/
/* remove path **/
this.cycle[--this.pathCount] = -1;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import java.util.Queue;
import java.util.Set;

/**
* An algorithm that sorts a graph in toplogical order.
*/
/**
* A class that represents the adjaceny list of a graph
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,50 @@

/**
* Java program that implements Kosaraju Algorithm.
* @author Shivanagouda S A (https://github.com/shivu2002a)
*
*/

/**
* @author <a href="https://github.com/shivu2002a">Shivanagouda S A</a>
* <p>
* Kosaraju algorithm is a linear time algorithm to find the strongly connected components of a
directed graph, which, from here onwards will be referred by SCC. It leverages the fact that the
transpose graph (same graph with all the edges reversed) has exactly the same SCCs as the original
graph.
directed graph, which, from here onwards will be referred by SCC. It leverages the fact that the
transpose graph (same graph with all the edges reversed) has exactly the same SCCs as the original
graph.

* A graph is said to be strongly connected if every vertex is reachable from every other vertex.
The SCCs of a directed graph form a partition into subgraphs that are themselves strongly
connected. Single node is always a SCC.
The SCCs of a directed graph form a partition into subgraphs that are themselves strongly
connected. Single node is always a SCC.

* Example:

0 <--- 2 -------> 3 -------- > 4 ---- > 7
| ^ | ^ ^
| / | \ /
| / | \ /
v / v \ /
1 5 --> 6
0 <--- 2 -------> 3 -------- > 4 ---- > 7
| ^ | ^ ^
| / | \ /
| / | \ /
v / v \ /
1 5 --> 6

For the above graph, the SCC list goes as follows:
0, 1, 2
3
4, 5, 6
7
For the above graph, the SCC list goes as follows:
0, 1, 2
3
4, 5, 6
7

We can also see that order of the nodes in an SCC doesn't matter since they are in cycle.
We can also see that order of the nodes in an SCC doesn't matter since they are in cycle.

{@summary}
{@summary}
* Kosaraju Algorithm:
1. Perform DFS traversal of the graph. Push node to stack before returning. This gives edges
sorted by lowest finish time.
2. Find the transpose graph by reversing the edges.
3. Pop nodes one by one from the stack and again to DFS on the modified graph.

The transpose graph of the above graph:
0 ---> 2 <------- 3 <------- 4 <------ 7
^ / ^ \ /
| / | \ /
| / | \ /
| v | v v
1 5 <--- 6

We can observe that this graph has the same SCC as that of original graph.
1. Perform DFS traversal of the graph. Push node to stack before returning. This gives edges
sorted by lowest finish time.
2. Find the transpose graph by reversing the edges.
3. Pop nodes one by one from the stack and again to DFS on the modified graph.

The transpose graph of the above graph:
0 ---> 2 <------- 3 <------- 4 <------ 7
^ / ^ \ /
| / | \ /
| / | \ /
| v | v v
1 5 <--- 6

We can observe that this graph has the same SCC as that of original graph.

*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,56 @@

/**
* Java program that implements Tarjan's Algorithm.
* @author Shivanagouda S A (https://github.com/shivu2002a)
*
*/

/**
* @author <a href="https://github.com/shivu2002a">Shivanagouda S A</a>
* <p>
* Tarjan's algorithm is a linear time algorithm to find the strongly connected components of a
directed graph, which, from here onwards will be referred as SCC.
directed graph, which, from here onwards will be referred as SCC.

* A graph is said to be strongly connected if every vertex is reachable from every other vertex.
The SCCs of a directed graph form a partition into subgraphs that are themselves strongly
connected. Single node is always a SCC.
The SCCs of a directed graph form a partition into subgraphs that are themselves strongly
connected. Single node is always a SCC.

* Example:
0 --------> 1 -------> 3 --------> 4
^ /
| /
| /
| /
| /
| /
| /
| /
| /
| /
|V
2

For the above graph, the SCC list goes as follows:
1, 2, 0
3
4

We can also see that order of the nodes in an SCC doesn't matter since they are in cycle.

{@summary}
Tarjan's Algorithm:
* DFS search produces a DFS tree
* Strongly Connected Components form subtrees of the DFS tree.
* If we can find the head of these subtrees, we can get all the nodes in that subtree (including
the head) and that will be one SCC.
* There is no back edge from one SCC to another (here can be cross edges, but they will not be
used).

* Kosaraju Algorithm aims at doing the same but uses two DFS traversalse whereas Tarjan’s
algorithm does the same in a single DFS, which leads to much lower constant factors in the latter.
0 --------> 1 -------> 3 --------> 4
^ /
| /
| /
| /
| /
| /
| /
| /
| /
| /
|V
2

For the above graph, the SCC list goes as follows:
1, 2, 0
3
4

We can also see that order of the nodes in an SCC doesn't matter since they are in cycle.

{@summary}
Tarjan's Algorithm:
* DFS search produces a DFS tree
* Strongly Connected Components form subtrees of the DFS tree.
* If we can find the head of these subtrees, we can get all the nodes in that subtree (including
the head) and that will be one SCC.
* There is no back edge from one SCC to another (here can be cross edges, but they will not be
used).

* Kosaraju Algorithm aims at doing the same but uses two DFS traversalse whereas Tarjan’s
algorithm does the same in a single DFS, which leads to much lower constant factors in the latter.

*/
public class TarjansAlgorithm {

// Timer for tracking lowtime and insertion time
private int time;

private List<List<Integer>> sccList = new ArrayList<List<Integer>>();
private final List<List<Integer>> sccList = new ArrayList<List<Integer>>();

public List<List<Integer>> stronglyConnectedComponents(int v, List<List<Integer>> graph) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,37 @@
/**
* Author : Suraj Kumar
* Github : https://github.com/skmodi649
*/
package com.thealgorithms.datastructures.lists;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
* @author <a href="https://github.com/skmodi649">Suraj Kumar</a>
* <p>
* PROBLEM DESCRIPTION :
* There is a single linked list and we are supposed to find a random node in the given linked list
*/

/**
* <p>
* ALGORITHM :
* Step 1 : START
* Step 2 : Create an arraylist of type integer
* Step 3 : Declare an integer type variable for size and linked list type for head
* Step 4 : We will use two methods, one for traversing through the linked list using while loop and
* also increase the size by 1
*
* <p>
* (a) RandomNode(head)
* (b) run a while loop till null;
* (c) add the value to arraylist;
* (d) increase the size;
*
* <p>
* Step 5 : Now use another method for getting random values using Math.random() and return the
* value present in arraylist for the calculated index Step 6 : Now in main() method we will simply
* insert nodes in the linked list and then call the appropriate method and then print the random
* node generated Step 7 : STOP
*/

package com.thealgorithms.datastructures.lists;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomNode {

private List<Integer> list;
private final List<Integer> list;
private int size;
private static Random rand = new Random();
private static final Random RAND = new Random();

static class ListNode {

Expand All @@ -63,10 +57,23 @@ public RandomNode(ListNode head) {
}

public int getRandom() {
int index = rand.nextInt(size);
int index = RAND.nextInt(size);
return list.get(index);
}

/**
* OUTPUT :
* First output :
* Random Node : 25
* Second output :
* Random Node : 78
* Time Complexity : O(n)
* Auxiliary Space Complexity : O(1)
* Time Complexity : O(n)
* Auxiliary Space Complexity : O(1)
* Time Complexity : O(n)
* Auxiliary Space Complexity : O(1)
*/
// Driver program to test above functions
public static void main(String[] args) {
ListNode head = new ListNode(15);
Expand All @@ -80,18 +87,3 @@ public static void main(String[] args) {
System.out.println("Random Node : " + randomNum);
}
}
/**
* OUTPUT :
* First output :
* Random Node : 25
* Second output :
* Random Node : 78
* Time Complexity : O(n)
* Auxiliary Space Complexity : O(1)
* Time Complexity : O(n)
* Auxiliary Space Complexity : O(1)
*/
/**
* Time Complexity : O(n)
* Auxiliary Space Complexity : O(1)
*/
Loading