Skip to content

Commit 9fbf2f5

Browse files
committed
Update GraphTreeCheck.java
1 parent 0125571 commit 9fbf2f5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/java/com/thealgorithms/tree/GraphTreeCheck.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
* Wikipedia Reference: https://en.wikipedia.org/wiki/Tree_(graph_theory)
1010
* Author: Aman
1111
*/
12-
13-
1412
class GraphTreeCheck {
1513

1614
private static final int MAX = 10;
17-
private int[][] adjMatrix = new int[MAX][MAX];
18-
private boolean[] visited = new boolean[MAX];
15+
private final int[][] adjMatrix = new int[MAX][MAX];
16+
private final boolean[] visited = new boolean[MAX];
1917
private int nodes;
2018

2119
public static void main(String[] args) {
@@ -40,6 +38,8 @@ public static void main(String[] args) {
4038
} else {
4139
System.out.println("The graph is NOT a tree.");
4240
}
41+
42+
in.close();
4343
}
4444

4545
public boolean isTree() {
@@ -73,6 +73,7 @@ private boolean hasCycle(int current, int parent) {
7373
}
7474
}
7575
}
76+
7677
return false;
7778
}
7879
}

0 commit comments

Comments
 (0)