public interface GraphInterface
Modifier and Type | Method and Description |
---|---|
void |
addEdge(Edge e)
Adds to the graph a new edge
|
void |
addEdge(int tail,
int head)
Adds to the graph a new edge
|
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
|
int |
getEdgeNum()
The number of edges of this graph
|
java.lang.Iterable<java.lang.Integer> |
getNeighbors(int u)
Returns the neighbors of node u, as an iterable
|
int |
getOrder()
The number of nodes of this graph
|
java.lang.Iterable<Edge> |
getOutEdges(int u)
Returns the edges incident to node u, as an iterable
|
boolean |
hasEdge(Edge e)
Whether this graph has the specified edge
|
boolean |
hasEdge(int tail,
int head)
Whether this graph has the specified edge
|
void |
removeEdge(int tail,
int head)
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
|
GraphInterface create()
GraphInterface create(int order)
order
- the number of nodesvoid addEdge(int tail, int head)
tail
- tail of the new edgehead
- head of the new edgevoid addEdge(int tail, int head, int weight)
tail
- tail of the new edgehead
- head of the new edgeweight
- weight of the new edgevoid addEdge(Edge e)
e
- the new edge that is to be addedboolean hasEdge(int tail, int head)
tail
- of the sought edgehead
- of the sought edgeboolean hasEdge(Edge e)
e
- the edgeint getOrder()
int getEdgeNum()
void removeEdge(int tail, int head)
tail
- tail of the edge to be removedhead
- head of the edge to be removedjava.lang.Iterable<java.lang.Integer> getNeighbors(int u)
u
- the node whose neighbors are requiredjava.lang.Iterable<Edge> getOutEdges(int u)
u
- the node whose incident edges are requiredjava.lang.String serialize()