Skip to content

Commit 1190b98

Browse files
authored
Update AStarSearch.java
1 parent e400522 commit 1190b98

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/main/java/com/thealgorithms/graph/AStarSearch.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.thealgorithms.graph;
1+
package com.thealgorithms.graphs;
22

33
import java.util.ArrayList;
44
import java.util.Collections;
@@ -7,14 +7,14 @@
77
import java.util.List;
88
import java.util.Map;
99
import java.util.PriorityQueue;
10-
import java.util.Set;
1110
import java.util.Scanner;
11+
import java.util.Set;
1212

1313
/**
14-
* Implementation of the A* Search Algorithm for shortest pathfinding.
14+
* Implementation of the A* Search Algorithm for shortest path finding.
1515
*
1616
* <p>
17-
* A* combines Dijkstras algorithm with a heuristic to efficiently find the
17+
* A* combines Dijkstra's algorithm with a heuristic to efficiently find the
1818
* shortest path in weighted graphs.
1919
* </p>
2020
*
@@ -23,18 +23,18 @@
2323
* </p>
2424
*
2525
* <p>
26-
* Time Complexity: O(E + V log V) with a binary heap priority queue.<br>
26+
* Time Complexity: O(E + V log V) with a binary heap priority queue.
2727
* Space Complexity: O(V + E)
2828
* </p>
2929
*/
3030
public class AStarSearch {
3131

3232
private static class Node implements Comparable<Node> {
33-
int id;
34-
double g; // cost from start
35-
double h; // heuristic to goal
36-
double f; // total cost = g + h
37-
Node parent;
33+
private final int id;
34+
private final double g; // cost from start
35+
private final double h; // heuristic to goal
36+
private final double f; // total cost = g + h
37+
private final Node parent;
3838

3939
Node(int id, double g, double h, Node parent) {
4040
this.id = id;
@@ -65,8 +65,8 @@ public AStarSearch() {
6565
* @param weight edge weight
6666
*/
6767
public void addEdge(int u, int v, int weight) {
68-
graph.computeIfAbsent(u, k -> new ArrayList<>()).add(new int[]{v, weight});
69-
graph.computeIfAbsent(v, k -> new ArrayList<>()).add(new int[]{u, weight});
68+
graph.computeIfAbsent(u, k -> new ArrayList<>()).add(new int[] {v, weight});
69+
graph.computeIfAbsent(v, k -> new ArrayList<>()).add(new int[] {u, weight});
7070
}
7171

7272
/**

0 commit comments

Comments
 (0)