Skip to content

Commit

Permalink
formatted DSF.java
Browse files Browse the repository at this point in the history
  • Loading branch information
DBasu2610 committed Sep 30, 2024
1 parent 80f9070 commit e294765
Showing 1 changed file with 38 additions and 42 deletions.
80 changes: 38 additions & 42 deletions Solved-Problems/GraphTheory/DFS.java
Original file line number Diff line number Diff line change
@@ -1,81 +1,77 @@
package DSA.DSA.SolvedProblems.GraphTheory;

Check warning on line 1 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 Package name 'DSA.DSA.SolvedProblems.GraphTheory' must match pattern '^[a-z]+(\.[a-z][a-z0-9]*)*$'. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:1:9: warning: Package name 'DSA.DSA.SolvedProblems.GraphTheory' must match pattern '^[a-z]+(\.[a-z][a-z0-9]*)*$'. (com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck)


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

public class DFS {

Check warning on line 8 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:8:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)

Check warning on line 8 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 Abbreviation in name 'DFS' must contain no more than '1' consecutive capital letters. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:8:14: warning: Abbreviation in name 'DFS' must contain no more than '1' consecutive capital letters. (com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck)
// 1- --3
// / | \
// 0 | 5--6
// \ | /
// 2-- - 4
// 1- --3
// / | \
// 0 | 5--6
// \ | /
// 2-- - 4

public static void main(String[] args) {

Check warning on line 15 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 'method def modifier' has incorrect indentation level 4, expected level should be 2. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:15:5: warning: 'method def modifier' has incorrect indentation level 4, expected level should be 2. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)

Check warning on line 15 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:15:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
int vertex = 7;

Check warning on line 16 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 'method def' child has incorrect indentation level 8, expected level should be 4. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:16:9: warning: 'method def' child has incorrect indentation level 8, expected level should be 4. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
ArrayList<Edge> graph[] = new ArrayList[vertex];

Check warning on line 17 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 'method def' child has incorrect indentation level 8, expected level should be 4. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:17:9: warning: 'method def' child has incorrect indentation level 8, expected level should be 4. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)

Check warning on line 17 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 Array brackets at illegal position. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:17:30: warning: Array brackets at illegal position. (com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck)
boolean vis[] = new boolean[vertex];

Check warning on line 18 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 'method def' child has incorrect indentation level 8, expected level should be 4. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:18:9: warning: 'method def' child has incorrect indentation level 8, expected level should be 4. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)

Check warning on line 18 in Solved-Problems/GraphTheory/DFS.java

View workflow job for this annotation

GitHub Actions / java-linter / java-linter

[reviewdog] reported by reviewdog 🐶 Array brackets at illegal position. Raw Output: /github/workspace/./Solved-Problems/GraphTheory/DFS.java:18:20: warning: Array brackets at illegal position. (com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck)

createGraph(graph);

depthFirst(graph,0,vis);
depthFirst(graph, 0, vis);
System.out.println();
}


static class Edge {
static class Edge {
int src;
int dest;

public Edge(int s, int d) {
this.src = s;
this.dest = d;
}
}
}

public static void createGraph(ArrayList<Edge> graph[]) {
for (int i = 0; i < graph.length; i++) {
graph[i] = new ArrayList<Edge>();
}
graph[0].add(new Edge(0,1));
graph[0].add(new Edge(0,2));

graph[1].add(new Edge(1,0));
graph[1].add(new Edge(1,3));

graph[2].add(new Edge(2,0));
graph[2].add(new Edge(2,4));

graph[3].add(new Edge(3,1));
graph[3].add(new Edge(3,4));
graph[3].add(new Edge(3,5));

graph[4].add(new Edge(4,2));
graph[4].add(new Edge(4,3));
graph[4].add(new Edge(4,5));

graph[5].add(new Edge(5,3));
graph[5].add(new Edge(5,4));
graph[5].add(new Edge(5,6));

graph[6].add(new Edge(6,5));



graph[0].add(new Edge(0, 1));
graph[0].add(new Edge(0, 2));

graph[1].add(new Edge(1, 0));
graph[1].add(new Edge(1, 3));

graph[2].add(new Edge(2, 0));
graph[2].add(new Edge(2, 4));

graph[3].add(new Edge(3, 1));
graph[3].add(new Edge(3, 4));
graph[3].add(new Edge(3, 5));

graph[4].add(new Edge(4, 2));
graph[4].add(new Edge(4, 3));
graph[4].add(new Edge(4, 5));

graph[5].add(new Edge(5, 3));
graph[5].add(new Edge(5, 4));
graph[5].add(new Edge(5, 6));

graph[6].add(new Edge(6, 5));

}

public static void depthFirst(ArrayList<Edge> graph[],int curr, boolean vis[]) {
public static void depthFirst(ArrayList<Edge> graph[], int curr, boolean vis[]) {
System.out.println(curr);
vis[curr] = true;
for (int i = 0; i < graph[curr].size(); i++) {
Edge e = graph[curr].get(i);
if(vis[e.dest]==false) {
depthFirst(graph, e.dest, vis);
if (vis[e.dest] == false) {
depthFirst(graph, e.dest, vis);
}
}

}

}
}

}

0 comments on commit e294765

Please sign in to comment.