|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.stanford.nlp.graph.DirectedMultiGraph<V,E>
V - Type of verticesE - Type of edges.public class DirectedMultiGraph<V,E>
Simple graph library; this is directed for now. This class focuses on time efficiency rather than memory efficiency.
| Constructor Summary | |
|---|---|
DirectedMultiGraph()
|
|
| 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> |
convertPath(java.util.List<V> nodes,
boolean directionSensitive)
|
java.lang.Iterable<E> |
edgeIterable()
|
java.util.Iterator<E> |
edgeIterator()
|
boolean |
equals(java.lang.Object that)
|
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)
Gets both parents and children nodes |
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 |
java.util.List<V> |
getShortestPath(V node1,
V node2)
direction insensitive (the paths can go "up" or through the parents) |
java.util.List<V> |
getShortestPath(V node1,
V node2,
boolean directionSensitive)
can specify the direction sensitivity |
java.util.List<E> |
getShortestPathEdges(V node1,
V node2)
|
java.util.List<E> |
getShortestPathEdges(V node1,
V node2,
boolean directionSensitive)
|
int |
hashCode()
Be careful hashing these. |
java.lang.Iterable<E> |
incomingEdgeIterable(V vertex)
|
java.util.Iterator<E> |
incomingEdgeIterator(V vertex)
|
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)
|
java.lang.Iterable<E> |
outgoingEdgeIterable(V vertex)
|
java.util.Iterator<E> |
outgoingEdgeIterator(V vertex)
|
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 |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DirectedMultiGraph()
| Method Detail |
|---|
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object that)
equals in class java.lang.Objectpublic boolean addVertex(V v)
addVertex in interface Graph<V,E>v -
public void add(V source,
V dest,
E data)
add in interface Graph<V,E>source - dest - data -
public boolean removeEdges(V source,
V dest)
removeEdges in interface Graph<V,E>
public boolean removeEdge(V source,
V dest,
E data)
removeEdge in interface Graph<V,E>public boolean removeVertex(V vertex)
removeVertex in interface Graph<V,E>vertex -
public boolean removeVertices(java.util.Collection<V> vertices)
removeVertices in interface Graph<V,E>public int getNumVertices()
getNumVertices in interface Graph<V,E>public java.util.List<E> getOutgoingEdges(V v)
Graph
getOutgoingEdges in interface Graph<V,E>public java.util.List<E> getIncomingEdges(V v)
Graph
getIncomingEdges in interface Graph<V,E>public int getNumEdges()
getNumEdges in interface Graph<V,E>public java.util.Set<V> getParents(V vertex)
Graph
getParents in interface Graph<V,E>public java.util.Set<V> getChildren(V vertex)
Graph
getChildren in interface Graph<V,E>public java.util.Set<V> getNeighbors(V v)
getNeighbors in interface Graph<V,E>v - public void clear()
clear in interface Graph<V,E>public boolean containsVertex(V v)
containsVertex in interface Graph<V,E>
public boolean isEdge(V source,
V dest)
isEdge in interface Graph<V,E>source - dest -
public boolean isNeighbor(V source,
V dest)
isNeighbor in interface Graph<V,E>public java.util.Set<V> getAllVertices()
getAllVertices in interface Graph<V,E>public java.util.List<E> getAllEdges()
getAllEdges in interface Graph<V,E>public boolean isEmpty()
isEmpty in interface Graph<V,E>public void removeZeroDegreeNodes()
removeZeroDegreeNodes in interface Graph<V,E>
public java.util.List<E> getEdges(V source,
V dest)
getEdges in interface Graph<V,E>
public java.util.List<V> getShortestPath(V node1,
V node2)
public java.util.List<E> getShortestPathEdges(V node1,
V node2)
public java.util.List<V> getShortestPath(V node1,
V node2,
boolean directionSensitive)
node1 - node2 - directionSensitive - - whether the path can go through the parents
public java.util.List<E> getShortestPathEdges(V node1,
V node2,
boolean directionSensitive)
public java.util.List<E> convertPath(java.util.List<V> nodes,
boolean directionSensitive)
public int getInDegree(V vertex)
Graph
getInDegree in interface Graph<V,E>public int getOutDegree(V vertex)
getOutDegree in interface Graph<V,E>public java.util.List<java.util.Set<V>> getConnectedComponents()
getConnectedComponents in interface Graph<V,E>public java.util.Iterator<E> incomingEdgeIterator(V vertex)
public java.lang.Iterable<E> incomingEdgeIterable(V vertex)
public java.util.Iterator<E> outgoingEdgeIterator(V vertex)
public java.lang.Iterable<E> outgoingEdgeIterable(V vertex)
public java.util.Iterator<E> edgeIterator()
public java.lang.Iterable<E> edgeIterable()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||