/** * Returns the first edge between the two vertices. * @param v1 The first vertex. * @param v2 The second vertex. * @return The edge or <code>null</code> if there is no incident edge * between the vertices. */ public Object findEdge(Object v1, Object v2) { return (IComponentGroup)delegate.findEdge(v1, v2); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, * java.lang.Object) */ @Override public synchronized E findEdge(V v1, V v2) { return delegate.findEdge(v1, v2); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, * java.lang.Object) */ @Override public E findEdge(V v1, V v2) { return delegate.findEdge(v1, v2); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, java.lang.Object) */ public E findEdge(V v1, V v2) { return delegate.findEdge(v1, v2); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, * java.lang.Object) */ @Override public E findEdge(V v1, V v2) { return delegate.findEdge(v1, v2); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, java.lang.Object) */ public synchronized E findEdge(V v1, V v2) { return delegate.findEdge(v1, v2); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, java.lang.Object) */ public E findEdge(V v1, V v2) { return delegate.findEdge(v1, v2); }
public E findEdge(V v1, V v2) { return graph.findEdge(v1, v2); } public Collection<E> findEdgeSet(V v1, V v2) {
/** * Returns the weight of the edge from <code>v1</code> to <code>v2</code> * plus the weight of the edge from <code>v2</code> to <code>v1</code>; * if either edge does not exist, it is treated as an edge with weight 0. * Undirected edges are treated as two antiparallel directed edges (that * is, if there is one undirected edge with weight <i>w</i> connecting * <code>v1</code> to <code>v2</code>, the value returned is 2<i>w</i>). * Ignores parallel edges; if there are any such, one is chosen at random. * Throws <code>NullPointerException</code> if either edge is * present but not assigned a weight by the constructor-specified * <code>NumberEdgeValue</code>. * * @param v1 the first vertex of the pair whose property is being measured * @param v2 the second vertex of the pair whose property is being measured * @return the weights of the edges {@code<v1, v2>} and {@code <v2, v1>} */ protected double mutualWeight(V v1, V v2) { E e12 = g.findEdge(v1,v2); E e21 = g.findEdge(v2,v1); double w12 = (e12 != null ? edge_weight.apply(e12).doubleValue() : 0); double w21 = (e21 != null ? edge_weight.apply(e21).doubleValue() : 0); return w12 + w21; }
/** * Returns the weight of the edge from <code>v1</code> to <code>v2</code> * plus the weight of the edge from <code>v2</code> to <code>v1</code>; * if either edge does not exist, it is treated as an edge with weight 0. * Undirected edges are treated as two antiparallel directed edges (that * is, if there is one undirected edge with weight <i>w</i> connecting * <code>v1</code> to <code>v2</code>, the value returned is 2<i>w</i>). * Ignores parallel edges; if there are any such, one is chosen at random. * Throws <code>NullPointerException</code> if either edge is * present but not assigned a weight by the constructor-specified * <code>NumberEdgeValue</code>. */ protected double mutualWeight(V v1, V v2) { E e12 = g.findEdge(v1,v2); E e21 = g.findEdge(v2,v1); double w12 = (e12 != null ? edge_weight.transform(e12).doubleValue() : 0); double w21 = (e21 != null ? edge_weight.transform(e21).doubleValue() : 0); return w12 + w21; }
/** * @param target * @param e * @param incident */ private static <S, T> void populateTarget(Graph<S, Collection<T>> target, T e, ArrayList<S> incident) { for (int i = 0; i < incident.size(); i++) { S v1 = incident.get(i); for (int j = i + 1; j < incident.size(); j++) { S v2 = incident.get(j); Collection<T> e_coll = target.findEdge(v1, v2); if (e_coll == null) { e_coll = new ArrayList<T>(); target.addEdge(e_coll, v1, v2); } e_coll.add(e); } } }
/** * Returns the weight of the edge from <code>v1</code> to <code>v2</code> * plus the weight of the edge from <code>v2</code> to <code>v1</code>; if * either edge does not exist, it is treated as an edge with weight 0. * Undirected edges are treated as two antiparallel directed edges (that is, * if there is one undirected edge with weight <i>w</i> connecting * <code>v1</code> to <code>v2</code>, the value returned is 2<i>w</i>). * Ignores parallel edges; if there are any such, one is chosen at random. * Throws <code>NullPointerException</code> if either edge is present but * not assigned a weight by the constructor-specified * <code>NumberEdgeValue</code>. */ protected double mutualWeight(V v1, V v2) { E e12 = g.findEdge(v1, v2); E e21 = g.findEdge(v2, v1); double w12 = (e12 != null ? edge_weight.transform(e12).doubleValue() : 0); double w21 = (e21 != null ? edge_weight.transform(e21).doubleValue() : 0); return w12 + w21; }
/** * @param target * @param e * @param incident */ private static <S,T> void populateTarget(Graph<S, Collection<T>> target, T e, ArrayList<S> incident) { for (int i = 0; i < incident.size(); i++) { S v1 = incident.get(i); for (int j = i+1; j < incident.size(); j++) { S v2 = incident.get(j); Collection<T> e_coll = target.findEdge(v1, v2); if (e_coll == null) { e_coll = new ArrayList<T>(); target.addEdge(e_coll, v1, v2); } e_coll.add(e); } } }
/** * @param target * @param e * @param incident */ private static <S,T> void populateTarget(Graph<S, Collection<T>> target, T e, ArrayList<S> incident) { for (int i = 0; i < incident.size(); i++) { S v1 = incident.get(i); for (int j = i+1; j < incident.size(); j++) { S v2 = incident.get(j); Collection<T> e_coll = target.findEdge(v1, v2); if (e_coll == null) { e_coll = new ArrayList<T>(); target.addEdge(e_coll, v1, v2); } e_coll.add(e); } } }
continue; newGraph.addVertex(t); Collection<V> v_coll = newGraph.findEdge(v, t); if (v_coll == null)
/** Find and remove simple loops (e.g. a -> b -> a) from a Jung graph */ public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }
/** Find and remove simple loops (e.g. a -> b -> a) from a Jung graph */ public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }
private void addAnnotatorDependencies( Graph<AnalysisEngine, Integer> graph, AnalysisEngine ae1, AnalysisEngine ae2) { // If there's already a dependency, then just return as we don't want multiple edges if (graph.findEdge(ae1, ae2) != null) return; // If the inputs of ae1 match the outputs of ae2, then ae1 is dependent on ae2 // We don't need to check both ways as this will be caught by the loop, although // we could be more efficient here. AnalysisEngineAction a1 = getAction(ae1); AnalysisEngineAction a2 = getAction(ae2); if (overlaps(a1.getInputs(), a2.getOutputs())) { graph.addEdge(++edgeId, ae2, ae1, EdgeType.DIRECTED); return; } }
private void addAnnotatorDependencies( Graph<AnalysisEngine, Integer> graph, AnalysisEngine ae1, AnalysisEngine ae2) { // If there's already a dependency, then just return as we don't want multiple edges if (graph.findEdge(ae1, ae2) != null) return; // If the inputs of ae1 match the outputs of ae2, then ae1 is dependent on ae2 // We don't need to check both ways as this will be caught by the loop, although // we could be more efficient here. AnalysisEngineAction a1 = getAction(ae1); AnalysisEngineAction a2 = getAction(ae2); if (overlaps(a1.getInputs(), a2.getOutputs())) { graph.addEdge(++edgeId, ae2, ae1, EdgeType.DIRECTED); return; } }
/** * Set the Graph's links so that it can be built. * * @param newlinks * All the Network-Topology Links. */ @Override public synchronized void setLinks(List<Link> newlinks) { CurrentLinks.clear(); CurrentLinks.addAll(newlinks); for (final Link link : newlinks) { NodeId sourceNodeId = link.getSource().getSourceNode(); NodeId destinationNodeId = link.getDestination().getDestNode(); if (networkGraph.findEdge(sourceNodeId, destinationNodeId) == null) { if (!networkGraph.containsVertex(sourceNodeId)) { networkGraph.addVertex(sourceNodeId); } if (!networkGraph.containsVertex(destinationNodeId)) { networkGraph.addVertex(destinationNodeId); } networkGraph.addEdge(link, sourceNodeId, destinationNodeId, EdgeType.DIRECTED); } } }