public final class DirectedGraph extends Object
| Constructor and Description |
|---|
DirectedGraph()
Constructs an empty
DirectedGraph with the default initial
vertex capacity (10). |
DirectedGraph(int initialCapacity)
Constructs an empty
DirectedGraph with the specified
initial vertex capacity. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Object vertex)
Adds a vertex.
|
void |
clear()
Remove all vertices and edges.
|
boolean |
contains(Object vertex)
Check to see if an object is a vertex.
|
boolean |
containsEdge(Object label1,
Object label2)
Check to see if an edge has been set between two vertices.
|
Iterator<Edge> |
edges()
Create an iterator of edges.
|
Edge[] |
edgesAsArray() |
Edge |
getEdge(Object vertex1,
Object vertex2) |
int |
getEdgeCount()
Get the total number of edges.
|
boolean |
isEmpty()
Check to see if there are any vertices defined.
|
Iterator<?> |
iterator()
Create an iterator of vertices.
|
Iterator<?> |
neighbors(Object label)
Create an iterator of all vertices that share an edge with a vertex.
|
Object |
remove(Object vertex)
Remove a vertex and all edges between the vertex and other vertices.
|
void |
setEdge(Object vertex1,
Object vertex2,
Weight weight)
Set the edge between two vertices.
|
int |
size()
Get the number of vertices.
|
public DirectedGraph(int initialCapacity)
DirectedGraph with the specified
initial vertex capacity.initialCapacity - the initial vertex capacity.public DirectedGraph()
DirectedGraph with the default initial
vertex capacity (10).public void clear()
public void add(Object vertex)
vertex - a vertex.public Object remove(Object vertex)
vertex - a vertex.public boolean contains(Object vertex)
vertex - the object.public int size()
public boolean isEmpty()
public void setEdge(Object vertex1, Object vertex2, Weight weight)
null weight unsets the
edge.vertex1 - a vertex.vertex2 - a vertex.weight - the value of the edge.public boolean containsEdge(Object label1, Object label2)
label1 - a vertex.label2 - a vertex.public int getEdgeCount()
public Iterator<?> iterator()
public Iterator<?> neighbors(Object label)
label - a vertex.public Edge[] edgesAsArray()
Copyright © 2012–2016 Emory University. All rights reserved.