/** * {@inheritDoc} */ @Override public V getEdgeSource(E e) { return delegate.getEdgeSource(e); }
/** * {@inheritDoc} */ @Override public V getEdgeSource(E e) { return base.getEdgeSource(e); }
public FlowElement getEdgeSource( Scope scope ) { return graph.getEdgeSource( scope ); }
private V getEdgeSource(E e) { return this.workingGraph.containsEdge(e) ? this.workingGraph.getEdgeSource(e) : this.originalGraph.getEdgeSource(e); }
public static <V, E> Set<V> sources(Graph<V, E> graph, Collection<E> edges) { Set<V> result = edges.stream() .map(e -> graph.getEdgeSource(e)) .collect(Collectors.toSet()); return result; }
public int[] getEdgeNumbers(E e) { V v1 = graph.getEdgeSource(e), v2 = graph.getEdgeTarget(e); int[] edge = new int[2]; edge[0] = mapVertexToOrder.get(v1); edge[1] = mapVertexToOrder.get(v2); return edge; }
private boolean isEqualsStraightOrInverted(Object sourceVertex, Object targetVertex, E e) { boolean equalStraight = sourceVertex.equals(graph.getEdgeSource(e)) && targetVertex.equals(graph.getEdgeTarget(e)); boolean equalInverted = sourceVertex.equals(graph.getEdgeTarget(e)) && targetVertex.equals(graph.getEdgeSource(e)); return equalStraight || equalInverted; }
/** * {@inheritDoc} */ @Override public V getEdgeSource(E edge) { assert (edgeSet().contains(edge)); return base.getEdgeSource(edge); }
/** * {@inheritDoc} */ @Override public Iterator<E> iterator() { return edgeSet .stream() .filter( e -> !edgeMask.test(e) && !vertexMask.test(graph.getEdgeSource(e)) && !vertexMask.test(graph.getEdgeTarget(e))) .iterator(); }
/** * {@inheritDoc} */ @Override public int size() { return (int) edgeSet .stream() .filter( e -> !edgeMask.test(e) && !vertexMask.test(graph.getEdgeSource(e)) && !vertexMask.test(graph.getEdgeTarget(e))) .count(); }
/** * {@inheritDoc} */ @Override public boolean contains(Object o) { if (!edgeSet.contains(o)) { return false; } E e = TypeUtil.uncheckedCast(o); return !edgeMask.test(e) && !vertexMask.test(graph.getEdgeSource(e)) && !vertexMask.test(graph.getEdgeTarget(e)); }
@Override public Set<E> getCutEdges() { Set<E> cutEdges = new LinkedHashSet<>(); Set<V> sourcePartion = this.getSourcePartition(); for (E e : network.edgeSet()) { V source = network.getEdgeSource(e); V sink = network.getEdgeTarget(e); if (sourcePartion.contains(source) ^ sourcePartion.contains(sink)) cutEdges.add(e); } return cutEdges; } }
public static <V, E> Triplet<V, E> toTriplet(Graph<V, E> graph, E edge) { V s = graph.getEdgeSource(edge); V t = graph.getEdgeTarget(edge); Triplet<V, E> result = new TripletImpl<>(s, edge, t); return result; }
private void debugCompatibleEdges( Collection<Scope> results, int v1, int v2, List<ScopeExpression> matchers ) { for( Scope result : results ) { FlowElement lhs = elementGraph.getDelegate().getEdgeSource( result ); int lhsIndex = elementGraph.getIndex( lhs ); FlowElement rhs = elementGraph.getDelegate().getEdgeTarget( result ); int rhsIndex = elementGraph.getIndex( rhs ); LOG.debug( "compatible edge: {}:{} -> {}:{}, having: {}", lhsIndex, lhs, rhsIndex, rhs, result.printSimple() ); } for( ScopeExpression matcher : matchers ) LOG.debug( " - {} -> {} matcher: {}", v1, v2, matcher ); }
static public <V, E> void copyTo(Graph<V, E> source, Graph<V, E> target) { for (V vertex : source.vertexSet()) { target.addVertex(vertex); } for (E edge : source.edgeSet()) { final boolean added = target.addEdge(source.getEdgeSource(edge), source.getEdgeTarget(edge), edge); if (!added) { throw new IllegalArgumentException("Target graph does not support addition of (some) source edges."); } } }
/** * {@inheritDoc} */ @Override public void addEdgeToTouchingVertices(E e) { V source = graph.getEdgeSource(e); V target = graph.getEdgeTarget(e); getEdgeContainer(source).addEdge(e); if (!source.equals(target)) { getEdgeContainer(target).addEdge(e); } }
/** * {@inheritDoc} */ @Override public void removeEdgeFromTouchingVertices(E e) { V source = graph.getEdgeSource(e); V target = graph.getEdgeTarget(e); getEdgeContainer(source).removeEdge(e); if (!source.equals(target)) { getEdgeContainer(target).removeEdge(e); } }
/** * {@inheritDoc} */ @Override public void addEdgeToTouchingVertices(E e) { V source = graph.getEdgeSource(e); V target = graph.getEdgeTarget(e); getEdgeContainer(source).addOutgoingEdge(e); getEdgeContainer(target).addIncomingEdge(e); }
/** * {@inheritDoc} */ @Override public void removeEdgeFromTouchingVertices(E e) { V source = graph.getEdgeSource(e); V target = graph.getEdgeTarget(e); getEdgeContainer(source).removeOutgoingEdge(e); getEdgeContainer(target).removeIncomingEdge(e); }
public DirectedMultiGraph( Graph<FlowElement, Scope> parent ) { this(); // safe to assume there are no unconnected vertices for( Scope edge : parent.edgeSet() ) { FlowElement s = parent.getEdgeSource( edge ); FlowElement t = parent.getEdgeTarget( edge ); addVertex( s ); addVertex( t ); addEdge( s, t, edge ); } }