View Javadoc
1   /*
2    * Created on Sep 24, 2005
3    *
4    * Copyright (c) 2005, The JUNG Authors 
5    *
6    * All rights reserved.
7    *
8    * This software is open-source under the BSD license; see either
9    * "license.txt" or
10   * https://github.com/jrtom/jung/blob/master/LICENSE for a description.
11   */
12  package edu.uci.ics.jung.graph.util;
13  
14  import edu.uci.ics.jung.graph.Graph;
15  
16  
17  /**
18   * An interface for a service to access the index of a given edge (in a given graph)
19   * into the set formed by the given edge and all the other edges it is parallel to.
20   * 
21   * <p>Note that in current use, this index is assumed to be an integer value in
22   * the interval [0,n-1], where n-1 is the number of edges parallel to <code>e</code>.
23   * 
24   * @author Tom Nelson 
25   *
26   */
27  public interface EdgeIndexFunction<V,E> {
28      
29      /**
30       * Returns <code>e</code>'s index in <code>graph</code>.
31       * The index of <code>e</code> is defined as its position in some 
32       * consistent ordering of <code>e</code> and all edges parallel to <code>e</code>.
33       * @param graph the graph with respect to which the index is calculated
34       * @param e the edge whose index is to be queried
35       * @return <code>e</code>'s index in <code>graph</code>
36       */
37      int getIndex(Graph<V, E> graph, E e);
38      
39      /**
40       * Resets the indices for <code>edge</code> and its parallel edges in <code>graph</code>.
41       * Should be invoked when an edge parallel to <code>edge</code>
42       * has been added or removed.
43       * 
44       * @param g the graph in which <code>edge</code>'s index is to be reset
45       * @param edge the edge whose index is to be reset
46       */
47      void reset(Graph<V,E> g, E edge);
48      
49      /**
50       * Clears all edge indices for all edges in all graphs.
51       * Does not recalculate the indices.
52       */
53      void reset();
54  }