コード例 #1
0
 /**
  * Returns the index for the specified edge. Calculates the indices for <code>e</code> and for all
  * edges parallel to <code>e</code>.
  */
 public int getIndex(Graph<V, E> graph, E e) {
   Integer index = edge_index.get(e);
   if (index == null) {
     Pair<V> endpoints = graph.getEndpoints(e);
     V u = endpoints.getFirst();
     V v = endpoints.getSecond();
     if (u.equals(v)) {
       index = getIndex(graph, e, v);
     } else {
       index = getIndex(graph, e, u, v);
     }
   }
   return index.intValue();
 }
コード例 #2
0
 /**
  * Resets the indices for this edge and its parallel edges. Should be invoked when an edge
  * parallel to <code>e</code> has been added or removed.
  *
  * @param e
  */
 public void reset(Graph<V, E> graph, E e) {
   Pair<V> endpoints = graph.getEndpoints(e);
   getIndex(graph, e, endpoints.getFirst());
   getIndex(graph, e, endpoints.getFirst(), endpoints.getSecond());
 }