ObjectEdgeWeightedDigraph
public class EdgeWeightedDigraph
The EdgeWeightedDigraph class represents an directed graph of vertices named 0 through V-1, where each edge has a real-valued weight. It supports the following operations: add an edge to the graph, iterate over all of edges leaving a vertex. Parallel edges and self-loops are permitted.
For additional documentation, see Section 4.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
| Constructor Summary | |
|---|---|
EdgeWeightedDigraph(EdgeWeightedDigraph G)
Copy constructor. |
|
EdgeWeightedDigraph(In in)
Create an edge-weighted digraph from input stream. |
|
EdgeWeightedDigraph(int V)
Create an empty edge-weighted digraph with V vertices. |
|
EdgeWeightedDigraph(int V,
int E)
Create a edge-weighted digraph with V vertices and E edges. |
|
| Method Summary | |
|---|---|
void |
addEdge(DirectedEdge e)
Add the edge e to this digraph. |
Iterable<DirectedEdge> |
adj(int v)
Return the edges leaving vertex v as an Iterable. |
int |
E()
Return the number of edges in this digraph. |
Iterable<DirectedEdge> |
edges()
Return all edges in this graph as an Iterable. |
static void |
main(String[] args)
Test client. |
int |
outdegree(int v)
Return number of edges leaving v. |
String |
toString()
Return a string representation of this graph. |
int |
V()
Return the number of vertices in this digraph. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public EdgeWeightedDigraph(int V)
public EdgeWeightedDigraph(int V,
int E)
public EdgeWeightedDigraph(In in)
public EdgeWeightedDigraph(EdgeWeightedDigraph G)
| Method Detail |
|---|
public int V()
public int E()
public void addEdge(DirectedEdge e)
public Iterable<DirectedEdge> adj(int v)
public Iterable<DirectedEdge> edges()
public int outdegree(int v)
public String toString()
toString in class Objectpublic static void main(String[] args)