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

All Superinterfaces:
Serializable
All Known Implementing Classes:
DirectedMultiGraph

public interface Graph<V,E>
extends 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)
           
 List<E> getAllEdges()
           
 Set<V> getAllVertices()
           
 Set<V> getChildren(V vertex)
          for undirected graph, it is just the neighbors
 List<Set<V>> getConnectedComponents()
           
 List<E> getEdges(V source, V dest)
           
 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
 Set<V> getNeighbors(V v)
           
 int getNumEdges()
           
 int getNumVertices()
           
 int getOutDegree(V vertex)
           
 List<E> getOutgoingEdges(V v)
          for undirected graph, it is just the edges from the node
 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(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(Collection<V> vertices)

getNumVertices

int getNumVertices()

getOutgoingEdges

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

Parameters:
v -

getIncomingEdges

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

Parameters:
v -

getNumEdges

int getNumEdges()

getParents

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

Parameters:
vertex -

getChildren

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

Parameters:
vertex -

getNeighbors

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

Set<V> getAllVertices()

getAllEdges

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

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

List<Set<V>> getConnectedComponents()


Stanford NLP Group