public class EdgeWeightedGraph extends java.lang.Object
For additional documentation, see Section 4.3 of Algorithms, 4th Edition, by Robert Sedgewick and Kevin Wayne.
Constructor and Description |
---|
EdgeWeightedGraph(EdgeWeightedGraph G)
Copy constructor.
|
EdgeWeightedGraph(In in)
Create a weighted graph from input stream.
|
EdgeWeightedGraph(int V)
Create an empty edge-weighted graph with V vertices.
|
EdgeWeightedGraph(int V,
int E)
Create a random edge-weighted graph with V vertices and E edges.
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(Edge e)
Add the undirected edge e to this graph.
|
java.lang.Iterable<Edge> |
adj(int v)
Return the edges incident to vertex v as an Iterable.
|
int |
E()
Return the number of edges in this graph.
|
java.lang.Iterable<Edge> |
edges()
Return all edges in this graph as an Iterable.
|
static void |
main(java.lang.String[] args)
Test client.
|
java.lang.String |
toString()
Return a string representation of this graph.
|
int |
V()
Return the number of vertices in this graph.
|
public EdgeWeightedGraph(int V)
public EdgeWeightedGraph(int V, int E)
public EdgeWeightedGraph(In in)
public EdgeWeightedGraph(EdgeWeightedGraph G)
public int V()
public int E()
public void addEdge(Edge e)
public java.lang.Iterable<Edge> adj(int v)
public java.lang.Iterable<Edge> edges()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)