/** * @param candidates * Set of edges and nodes to test connectivity to. * @return True if the edge is directly connected at its end to at least one of the candidate * items */ public boolean isConnectedAtEndTo(final Set<? extends AtlasItem> candidates) { for (final AtlasItem item : candidates) { if (item instanceof Node && end().equals(item)) { return true; } if (item instanceof Edge && end().equals(((Edge) item).start())) { return true; } } return false; }
/** * @param candidates * Set of edges and nodes to test connectivity to. * @return True if the edge is directly connected at its start to at least one of the candidate * items */ public boolean isConnectedAtStartTo(final Set<? extends AtlasItem> candidates) { for (final AtlasItem item : candidates) { if (item instanceof Node && start().equals(item)) { return true; } if (item instanceof Edge && start().equals(((Edge) item).end())) { return true; } } return false; }
public Route prepend(final Route route) { if (!start().start().equals(route.end().end())) { throw new CoreException("Cannot prepend a disconnected route."); } return new MultiRoute(route, this); }
if (candidateRoute.start().start().equals(candidateRoute.end().end()))
public Route append(final Route route) { if (route == null) { throw new CoreException( "Cannot append a route that is null to a route {} that ends at {}", this, this.end()); } if (!end().end().equals(route.start().start())) { throw new CoreException( "Cannot append a disconnected route:\nOne: {}\nAt: {}\nTo\nTwo: {}\nAt: {}", this, this.end(), route, route.start()); } return new MultiRoute(this, route); }
@Override public Route route(final Edge start, final Edge end) { if (start == null || end == null) { throw new CoreException( "Cannot compute route on null arguments: start = {} and end = {}", start, end); } if (start.equals(end)) { // Same edge return Route.forEdge(start); } if (start.end().equals(end.start())) { // Directly connected edges return Route.forEdge(start).append(end); } final Route result = route(start.end(), end.start()); if (result != null) { // Re-populate the result with the start and end edges return Route.forEdge(start).append(result).append(end); } return null; }