public class DirectedGraph extends Graph implements GraphInterface
Constructor and Description |
---|
DirectedGraph(int nVert)
Creates a DirectedGraph with the specified number of nodes and no edges
|
DirectedGraph(java.lang.String graphDescription)
Creates a DirectedGraph as described by the input string.
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(int tail,
int head,
int weight)
Adds to the graph a new edge
|
GraphInterface |
create()
Creates a new object of the same class as this, with the same number of nodes and no edges
|
GraphInterface |
create(int order)
Creates a new object of the same class as this, with order nodes and no edges
|
void |
removeEdge(int u,
int v)
Removes the specified edge from the graph (if the egde exists)
|
java.lang.String |
serialize()
A String representation of the graph in the format:
"\n" separated lines; first line = number of nodes;
each subsequent line is an edge in the format: head tail weight
|
addEdge, addEdge, getEdgeNum, getNeighbors, getOrder, getOutEdges, hasEdge, hasEdge, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
addEdge, addEdge, getEdgeNum, getNeighbors, getOrder, getOutEdges, hasEdge, hasEdge
public DirectedGraph(int nVert)
nVert
- the number of nodespublic DirectedGraph(java.lang.String graphDescription)
graphDescription
- description of the graph.
Accepted formats:
public GraphInterface create()
GraphInterface
create
in interface GraphInterface
create
in class Graph
public GraphInterface create(int order)
GraphInterface
create
in interface GraphInterface
create
in class Graph
order
- the number of nodespublic void addEdge(int tail, int head, int weight)
GraphInterface
addEdge
in interface GraphInterface
addEdge
in class Graph
tail
- tail of the new edgehead
- head of the new edgeweight
- weight of the new edgepublic void removeEdge(int u, int v)
GraphInterface
removeEdge
in interface GraphInterface
removeEdge
in class Graph
u
- tail of the edge to be removedv
- head of the edge to be removedpublic java.lang.String serialize()
GraphInterface
serialize
in interface GraphInterface
serialize
in class Graph