edu.uci.ics.jung.graph.util
Class DefaultParallelEdgeIndexFunction<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.graph.util.DefaultParallelEdgeIndexFunction<V,E>
All Implemented Interfaces:
EdgeIndexFunction<V,E>

public class DefaultParallelEdgeIndexFunction<V,E>
extends Object
implements EdgeIndexFunction<V,E>

A class which creates and maintains indices for parallel edges. Parallel edges are defined here to be the collection of edges that are returned by v.findEdgeSet(w) for some v and w.

At this time, users are responsible for resetting the indices (by calling reset()) if changes to the graph make it appropriate.

Author:
Joshua O'Madadhain, Tom Nelson

Field Summary
protected  Map<Context<Graph<V,E>,E>,Integer> edge_index
           
 
Method Summary
 int getIndex(Graph<V,E> graph, E e)
          Returns the index for e in graph.
protected  int getIndex(Graph<V,E> graph, E e, V v)
           
protected  int getIndex(Graph<V,E> graph, E e, V v, V u)
           
static
<V,E> DefaultParallelEdgeIndexFunction<V,E>
getInstance()
          Returns an instance of this class.
 void reset()
          Clears all edge indices for all edges in all graphs.
 void reset(Graph<V,E> graph, E e)
          Resets the indices for this edge and its parallel edges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edge_index

protected Map<Context<Graph<V,E>,E>,Integer> edge_index
Method Detail

getInstance

public static <V,E> DefaultParallelEdgeIndexFunction<V,E> getInstance()
Returns an instance of this class.

Type Parameters:
V - the vertex type
E - the edge type

getIndex

public int getIndex(Graph<V,E> graph,
                    E e)
Returns the index for e in graph. Calculates the indices for e and for all edges parallel to e, if they are not already assigned.

Specified by:
getIndex in interface EdgeIndexFunction<V,E>
Parameters:
graph - the graph in which the edge is to be queried
e - the edge whose index is to be queried
Returns:
e's index in graph

getIndex

protected int getIndex(Graph<V,E> graph,
                       E e,
                       V v,
                       V u)

getIndex

protected int getIndex(Graph<V,E> graph,
                       E e,
                       V v)

reset

public void reset(Graph<V,E> graph,
                  E e)
Resets the indices for this edge and its parallel edges. Should be invoked when an edge parallel to e has been added or removed.

Specified by:
reset in interface EdgeIndexFunction<V,E>
Parameters:
e -
graph - the graph in which edge's index is to be reset

reset

public void reset()
Clears all edge indices for all edges in all graphs. Does not recalculate the indices.

Specified by:
reset in interface EdgeIndexFunction<V,E>


Copyright © 2009. All Rights Reserved.