@Override public double connectionLength(Point from, Point to) { checkArgument(hasConnection(from, to), "Can not get connection length from a non-existing connection."); final Optional<E> connData = connectionData(from, to); return connData.isPresent() && connData.get().getLength().isPresent() ? connData.get().getLength().get() : Point.distance(from, to); }
@Override public double connectionLength(Point from, Point to) { checkArgument(hasConnection(from, to), "Can not get connection length from a non-existing connection."); final Optional<E> connData = connectionData(from, to); return connData.isPresent() && connData.get().getLength().isPresent() ? connData.get().getLength().get() : Point.distance(from, to); }
/** * @return The length of this connection as specified by the data or * alternatively by the euclidean distance between the two points. */ public double getLength() { if (data().isPresent() && data().get().getLength().isPresent()) { return data().get().getLength().get(); } return Point.distance(from(), to()); }
/** * @return The length of this connection as specified by the data or * alternatively by the euclidean distance between the two points. */ public double getLength() { if (data().isPresent() && data().get().getLength().isPresent()) { return data().get().getLength().get(); } return Point.distance(from(), to()); }
assertTrue(graph.hasConnection(n3, n2)); assertEquals(1.4, graph.getConnection(n0, n1).data().get().getLength() .get().doubleValue(), 0); assertEquals(.8, graph.getConnection(n0, n19663).data().get().getLength() .get().doubleValue(), 0); assertEquals(1.0, graph.getConnection(n0, n16767).data().get().getLength() .get().doubleValue(), 0); assertEquals(1.4, graph.getConnection(n1, n0).data().get().getLength() .get().doubleValue(), 0); assertEquals(1.6, graph.getConnection(n1, n2).data().get().getLength() .get().doubleValue(), 0); assertEquals(1.6, graph.getConnection(n2, n1).data().get().getLength() .get().doubleValue(), 0); assertEquals(1.1, graph.getConnection(n2, n3).data().get().getLength() .get().doubleValue(), 0); assertEquals(1.1, graph.getConnection(n3, n2).data().get().getLength() .get().doubleValue(), 0);