Skip to content

Commit 973a9f2

Browse files
committed
Apply linter review
1 parent 7d5b09d commit 973a9f2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

exercises/practice/relative-distance/.meta/src/reference/java/RelativeDistance.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@
77

88
class RelativeDistance {
99

10-
private final Map<String, HashSet<String>> Graph;
10+
private final Map<String, HashSet<String>> graph;
1111

1212
RelativeDistance(Map<String, List<String>> familyTree) {
13-
final HashMap<String, HashSet<String>> graph = new HashMap<>();
13+
final HashMap<String, HashSet<String>> connections = new HashMap<>();
1414

1515
for (Map.Entry<String, List<String>> entry : familyTree.entrySet()) {
1616
String parent = entry.getKey();
1717
List<String> children = entry.getValue();
1818

19-
graph.putIfAbsent(parent, new HashSet<>());
19+
connections.putIfAbsent(parent, new HashSet<>());
2020

2121
for (String child : children) {
22-
graph.putIfAbsent(child, new HashSet<>());
22+
connections.putIfAbsent(child, new HashSet<>());
2323

24-
graph.get(parent).add(child);
25-
graph.get(child).add(parent);
24+
connections.get(parent).add(child);
25+
connections.get(child).add(parent);
2626

2727
for (String sibling : children) {
2828
if (!sibling.equals(child)) {
29-
graph.get(child).add(sibling);
29+
connections.get(child).add(sibling);
3030
}
3131
}
3232
}
3333
}
3434

35-
Graph = graph;
35+
graph = connections;
3636
}
3737

3838
int degreeOfSeparation(String personA, String personB) {
39-
if (!Graph.containsKey(personA) || !Graph.containsKey(personB)) {
39+
if (!graph.containsKey(personA) || !graph.containsKey(personB)) {
4040
return -1;
4141
}
4242

@@ -52,7 +52,7 @@ int degreeOfSeparation(String personA, String personB) {
5252
String current = queue.poll();
5353
int currentDistance = distances.get(current);
5454

55-
for (String relative : Graph.get(current)) {
55+
for (String relative : graph.get(current)) {
5656
if (!distances.containsKey(relative)) {
5757
if (relative.equals(personB)) {
5858
return currentDistance + 1;

0 commit comments

Comments
 (0)