Refine search
public V getOpposite(V vertex, E edge) { Pair<V> incident = this.getEndpoints(edge); V first = incident.getFirst(); V second = incident.getSecond(); if (vertex.equals(first)) return second; else if (vertex.equals(second)) return first; else throw new IllegalArgumentException(vertex + " is not incident to " + edge + " in this graph"); }
public boolean removeEdge(E edge) { if (!containsEdge(edge)) return false; Pair<V> endpoints = this.getEndpoints(edge); V source = endpoints.getFirst(); V dest = endpoints.getSecond(); // remove vertices from each others' adjacency maps vertices.get(source).getSecond().remove(dest); vertices.get(dest).getFirst().remove(source); edges.remove(edge); return true; } }
public boolean removeEdge(E edge) { if (!containsEdge(edge)) return false; Pair<V> endpoints = getEndpoints(edge); V v1 = endpoints.getFirst(); V v2 = endpoints.getSecond(); // remove edge from incident vertices' adjacency sets vertices.get(v1).remove(edge); vertices.get(v2).remove(edge); edges.remove(edge); return true; }
/** * @see edu.uci.ics.jung.graph.Graph#getOpposite(java.lang.Object, * java.lang.Object) */ @Override public V getOpposite(V vertex, E edge) { if (!containsVertex(vertex) || !containsEdge(edge)) { return null; } Pair<V> endpoints = edge_vpairs.get(edge); V v1 = endpoints.getFirst(); V v2 = endpoints.getSecond(); return v1.equals(vertex) ? v2 : v1; }
private CubicCurve2D secedgeCurve(VerticalOrientation verticalOrientation, Rectangle2D sourceRect, Rectangle2D targetRect) { Pair<RectangleSide> sidePair = findBestConnection(sourceRect, targetRect); Point2D startPoint = sideMidPoint(sourceRect, sidePair.getFirst()); Point2D endPoint = sideMidPoint(targetRect, sidePair.getSecond()); double middleX = (startPoint.getX() + endPoint.getX()) / 2.0; double middleY = 50 * -verticalOrientation.value + (startPoint.getY() + endPoint.getY()) / 2; return new CubicCurve2D.Double( startPoint.getX(), startPoint.getY(), middleX, middleY, middleX, middleY, endPoint.getX(), endPoint.getY()); }