Skip to content

Commit

Permalink
Adding try-with-resources block around PredictionTraverser (#2016)
Browse files Browse the repository at this point in the history
Co-authored-by: Sagar Rao <sagarrao@Sagars-MacBook-Pro.local>
  • Loading branch information
vamossagar12 and Sagar Rao authored Nov 15, 2022
1 parent 833ce2f commit b79a690
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ public String get(@Context GraphManager manager,
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));

HugeGraph g = graph(manager, graph);
PredictionTraverser traverser = new PredictionTraverser(g);
double score = traverser.adamicAdar(sourceId, targetId, dir,
edgeLabel, maxDegree, limit);
return JsonUtil.toJson(ImmutableMap.of("adamic_adar", score));
try (PredictionTraverser traverser = new PredictionTraverser(g)) {
double score = traverser.adamicAdar(sourceId, targetId, dir,
edgeLabel, maxDegree, limit);
return JsonUtil.toJson(ImmutableMap.of("adamic_adar", score));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ public String create(@Context GraphManager manager,
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));

HugeGraph g = graph(manager, graph);
PredictionTraverser traverser = new PredictionTraverser(g);
double score = traverser.resourceAllocation(sourceId, targetId, dir,
edgeLabel, maxDegree,
limit);
return JsonUtil.toJson(ImmutableMap.of("resource_allocation", score));
try (PredictionTraverser traverser = new PredictionTraverser(g)) {
double score = traverser.resourceAllocation(sourceId, targetId, dir,
edgeLabel, maxDegree,
limit);
return JsonUtil.toJson(ImmutableMap.of("resource_allocation", score));
}
}
}

0 comments on commit b79a690

Please sign in to comment.