public class Graph
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
CSet<DirectedEdge>[] |
adj |
int |
E |
int |
V |
Constructor and Description |
---|
Graph(int V)
Initializes a graph containing with V nodes and no edge (yet).
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(DirectedEdge e)
Adds the directed edge
e to this edge-weighted digraph. |
java.lang.Iterable<DirectedEdge> |
adj(int v)
Returns the directed edges incident from vertex
v . |
boolean |
isIn(DirectedEdge e) |
void |
merge(Graph G) |
void |
removeEdges(DirectedEdge e2remove) |
java.lang.String |
toString()
Returns a string representation of this edge-weighted digraph.
|
public int V
public int E
public CSet<DirectedEdge>[] adj
public Graph(int V)
V
- the number of verticespublic void merge(Graph G)
public void addEdge(DirectedEdge e)
e
to this edge-weighted digraph.e
- the edgejava.lang.IndexOutOfBoundsException
- unless endpoints of edge are between 0
and V-1
public boolean isIn(DirectedEdge e)
public void removeEdges(DirectedEdge e2remove)
public java.lang.Iterable<DirectedEdge> adj(int v)
v
.v
- the vertexv
as an Iterablejava.lang.IndexOutOfBoundsException
- unless 0 <= v < V
public java.lang.String toString()
toString
in class java.lang.Object