|
|||||||||
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)
|
List<E> |
convertPath(List<V> nodes,
boolean directionSensitive)
|
Iterable<E> |
edgeIterable()
|
Iterator<E> |
edgeIterator()
|
boolean |
equals(Object that)
|
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)
Gets both parents and children nodes |
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 |
List<V> |
getShortestPath(V node1,
V node2)
direction insensitive (the paths can go "up" or through the parents) |
List<V> |
getShortestPath(V node1,
V node2,
boolean directionSensitive)
can specify the direction sensitivity |
List<E> |
getShortestPathEdges(V node1,
V node2)
|
List<E> |
getShortestPathEdges(V node1,
V node2,
boolean directionSensitive)
|
int |
hashCode()
Be careful hashing these. |
Iterable<E> |
incomingEdgeIterable(V vertex)
|
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)
|
Iterable<E> |
outgoingEdgeIterable(V vertex)
|
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(Collection<V> vertices)
|
void |
removeZeroDegreeNodes()
Deletes nodes with zero incoming and zero outgoing edges |
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 Object
public boolean equals(Object that)
equals
in class Object
public 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(Collection<V> vertices)
removeVertices
in interface Graph<V,E>
public int getNumVertices()
getNumVertices
in interface Graph<V,E>
public List<E> getOutgoingEdges(V v)
Graph
getOutgoingEdges
in interface Graph<V,E>
public List<E> getIncomingEdges(V v)
Graph
getIncomingEdges
in interface Graph<V,E>
public int getNumEdges()
getNumEdges
in interface Graph<V,E>
public Set<V> getParents(V vertex)
Graph
getParents
in interface Graph<V,E>
public Set<V> getChildren(V vertex)
Graph
getChildren
in interface Graph<V,E>
public 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 Set<V> getAllVertices()
getAllVertices
in interface Graph<V,E>
public 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 List<E> getEdges(V source, V dest)
getEdges
in interface Graph<V,E>
public List<V> getShortestPath(V node1, V node2)
public List<E> getShortestPathEdges(V node1, V node2)
public List<V> getShortestPath(V node1, V node2, boolean directionSensitive)
node1
- node2
- directionSensitive
- - whether the path can go through the parents
public List<E> getShortestPathEdges(V node1, V node2, boolean directionSensitive)
public List<E> convertPath(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 List<Set<V>> getConnectedComponents()
getConnectedComponents
in interface Graph<V,E>
public Iterator<E> incomingEdgeIterator(V vertex)
public Iterable<E> incomingEdgeIterable(V vertex)
public Iterator<E> outgoingEdgeIterator(V vertex)
public Iterable<E> outgoingEdgeIterable(V vertex)
public Iterator<E> edgeIterator()
public Iterable<E> edgeIterable()
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |