Skip to content

Commit

Permalink
add null pointer exception try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Jun 17, 2024
1 parent 0cb6998 commit 9b0dc1d
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,10 +676,12 @@ public static <T extends NativeType<T>> SimpleWeightedGraph<Spot, DefaultWeigh
graph.addVertex(addsourcetarget.getB());

if (graph.degreeOf(addsourcetarget.getB()) < 2) {
final DefaultWeightedEdge edge = graph.addEdge(addsourcetarget.getA(),
addsourcetarget.getB());

graph.setEdgeWeight(edge, cost);
final DefaultWeightedEdge edge = graph.addEdge(addsourcetarget.getA(), addsourcetarget.getB());
if (edge != null && graph.containsEdge(edge)) {
graph.setEdgeWeight(edge, cost);
} else {
System.out.println("Failed to add edge or edge no longer exists between " + addsourcetarget.getA() + " and " + addsourcetarget.getB());
}
}
}
} catch (Exception e) {
Expand Down

0 comments on commit 9b0dc1d

Please sign in to comment.