edu.stanford.nlp.graph
Interface Graph<V,E>

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
DirectedMultiGraph

public interface Graph<V,E>
extends java.io.Serializable


Method Summary
 void add(V source, V dest, E data)
          Adds vertices (if not already in the graph) and the edge between them.
 boolean addVertex(V v)
          For adding a zero degree vertex
 void clear()
          clears the graph, removes all edges and nodes
 boolean containsVertex(V v)
           
 java.util.List<E> getAllEdges()
           
 java.util.Set<V> getAllVertices()
           
 java.util.Set<V> getChildren(V vertex)
          for undirected graph, it is just the neighbors
 java.util.List<java.util.Set<V>> getConnectedComponents()
           
 java.util.List<E> getEdges(V source, V dest)
           
 java.util.List<E> getIncomingEdges(V v)
          for undirected graph, it is just the edges from the node
 int getInDegree(V vertex)
          for undirected graph, it should just be the degree
 java.util.Set<V> getNeighbors(V v)
           
 int getNumEdges()
           
 int getNumVertices()
           
 int getOutDegree(V vertex)
           
 java.util.List<E> getOutgoingEdges(V v)
          for undirected graph, it is just the edges from the node
 java.util.Set<V> getParents(V vertex)
          for undirected graph, it is just the neighbors
 boolean isEdge(V source, V dest)
          only checks if there is an edge from source to dest.
 boolean isEmpty()
          False if there are any vertices in the graph, true otherwise.
 boolean isNeighbor(V source, V dest)
           
 boolean removeEdge(V source, V dest, E data)
           
 boolean removeEdges(V source, V dest)
           
 boolean removeVertex(V vertex)
          remove a vertex (and its edges) from the graph.
 boolean removeVertices(java.util.Collection<V> vertices)
           
 void removeZeroDegreeNodes()
          Deletes nodes with zero incoming and zero outgoing edges
 

Method Detail

add

void add(V source,
         V dest,
         E data)
Adds vertices (if not already in the graph) and the edge between them. (If the graph is undirected, the choice of which vertex to call source and dest is arbitrary.)

Parameters:
source -
dest -
data -

addVertex

boolean addVertex(V v)
For adding a zero degree vertex

Parameters:
v -

removeEdges

boolean removeEdges(V source,
                    V dest)

removeEdge

boolean removeEdge(V source,
                   V dest,
                   E data)

removeVertex

boolean removeVertex(V vertex)
remove a vertex (and its edges) from the graph.

Parameters:
vertex -
Returns:
true if successfully removes the node

removeVertices

boolean removeVertices(java.util.Collection<V> vertices)

getNumVertices

int getNumVertices()

getOutgoingEdges

java.util.List<E> getOutgoingEdges(V v)
for undirected graph, it is just the edges from the node

Parameters:
v -

getIncomingEdges

java.util.List<E> getIncomingEdges(V v)
for undirected graph, it is just the edges from the node

Parameters:
v -

getNumEdges

int getNumEdges()

getParents

java.util.Set<V> getParents(V vertex)
for undirected graph, it is just the neighbors

Parameters:
vertex -

getChildren

java.util.Set<V> getChildren(V vertex)
for undirected graph, it is just the neighbors

Parameters:
vertex -

getNeighbors

java.util.Set<V> getNeighbors(V v)

clear

void clear()
clears the graph, removes all edges and nodes


containsVertex

boolean containsVertex(V v)

isEdge

boolean isEdge(V source,
               V dest)
only checks if there is an edge from source to dest. To check if it is connected in either direction, use isNeighbor

Parameters:
source -
dest -

isNeighbor

boolean isNeighbor(V source,
                   V dest)

getAllVertices

java.util.Set<V> getAllVertices()

getAllEdges

java.util.List<E> getAllEdges()

isEmpty

boolean isEmpty()
False if there are any vertices in the graph, true otherwise. Does not care about the number of edges.


removeZeroDegreeNodes

void removeZeroDegreeNodes()
Deletes nodes with zero incoming and zero outgoing edges


getEdges

java.util.List<E> getEdges(V source,
                           V dest)

getInDegree

int getInDegree(V vertex)
for undirected graph, it should just be the degree

Parameters:
vertex -

getOutDegree

int getOutDegree(V vertex)

getConnectedComponents

java.util.List<java.util.Set<V>> getConnectedComponents()


Stanford NLP Group