Class NeighborIndex<V,​E>

  • Type Parameters:
    V - the graph vertex type
    E - the graph edge type
    All Implemented Interfaces:
    java.util.EventListener, GraphListener<V,​E>, VertexSetListener<V>

    public class NeighborIndex<V,​E>
    extends java.lang.Object
    implements GraphListener<V,​E>
    Maintains a cache of each vertex's neighbors. While lists of neighbors can be obtained from Graphs, they are re-calculated at each invocation by walking a vertex's incident edges, which becomes inordinately expensive when performed often.

    Edge direction is ignored when evaluating neighbors; to take edge direction into account when indexing neighbors, use DirectedNeighborIndex.

    A vertex's neighbors are cached the first time they are asked for (i.e. the index is built on demand). The index will only be updated automatically if it is added to the associated graph as a listener. If it is added as a listener to a graph other than the one it indexes, results are undefined.

    Since:
    Dec 13, 2005