DefaultWeightedEdge addEdge(final Spot source, final Spot target, final double weight) { if (!graph.containsVertex(source)) { graph.addVertex(source); } if (!graph.containsVertex(target)) { graph.addVertex(target); } final DefaultWeightedEdge edge = graph.addEdge(source, target); graph.setEdgeWeight(edge, weight); return edge; }
/** @see Graph#edgesOf(Object) */ public Set<DefaultWeightedEdge> edgesOf(final Spot spot) { if (graph.containsVertex(spot)) { return graph.edgesOf(spot); } else { return Collections.emptySet(); } }