V
 the graph vertex typeE
 the graph edge typepublic class DirectedNeighborIndex<V,E> extends Object implements GraphListener<V,E>
Graphs
, they are recalculated at each invocation by walking a vertex's incident edges,
which becomes inordinately expensive when performed often.
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.
Constructor and Description 

DirectedNeighborIndex(DirectedGraph<V,E> g)
Creates a neighbor index for the specified directed graph.

Modifier and Type  Method and Description 

void 
edgeAdded(GraphEdgeChangeEvent<V,E> e)
Notifies that an edge has been added to the graph.

void 
edgeRemoved(GraphEdgeChangeEvent<V,E> e)
Notifies that an edge has been removed from the graph.

List<V> 
predecessorListOf(V v)
Returns the set of vertices which are the predecessors of a specified vertex.

Set<V> 
predecessorsOf(V v)
Returns the set of vertices which are the predecessors of a specified vertex.

List<V> 
successorListOf(V v)
Returns the set of vertices which are the successors of a specified vertex.

Set<V> 
successorsOf(V v)
Returns the set of vertices which are the successors of a specified vertex.

void 
vertexAdded(GraphVertexChangeEvent<V> e)
Notifies that a vertex has been added to the graph.

void 
vertexRemoved(GraphVertexChangeEvent<V> e)
Notifies that a vertex has been removed from the graph.

public DirectedNeighborIndex(DirectedGraph<V,E> g)
g
 the graph for which a neighbor index is to be created.public Set<V> predecessorsOf(V v)
v
 the vertex whose predecessors are desiredpublic List<V> predecessorListOf(V v)
predecessorsOf(Object)
unless duplicate neighbors are required.v
 the vertex whose predecessors are desiredpublic Set<V> successorsOf(V v)
v
 the vertex whose successors are desiredpublic List<V> successorListOf(V v)
successorsOf(Object)
unless duplicate neighbors are required.v
 the vertex whose successors are desiredpublic void edgeAdded(GraphEdgeChangeEvent<V,E> e)
GraphListener
edgeAdded
in interface GraphListener<V,E>
e
 the edge event.GraphListener.edgeAdded(GraphEdgeChangeEvent)
public void edgeRemoved(GraphEdgeChangeEvent<V,E> e)
GraphListener
edgeRemoved
in interface GraphListener<V,E>
e
 the edge event.GraphListener.edgeRemoved(GraphEdgeChangeEvent)
public void vertexAdded(GraphVertexChangeEvent<V> e)
VertexSetListener
vertexAdded
in interface VertexSetListener<V>
e
 the vertex event.VertexSetListener.vertexAdded(GraphVertexChangeEvent)
public void vertexRemoved(GraphVertexChangeEvent<V> e)
VertexSetListener
vertexRemoved
in interface VertexSetListener<V>
e
 the vertex event.VertexSetListener.vertexRemoved(GraphVertexChangeEvent)
Copyright © 2016. All rights reserved.