-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphInterface.java
More file actions
executable file
·39 lines (25 loc) · 1.2 KB
/
GraphInterface.java
File metadata and controls
executable file
·39 lines (25 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// package GraphGame;
import java.util.Iterator;
public interface GraphInterface<V> {
// returns number of vertices in the graph
public int getNumVertices();
// returns number of edges in the graph
public int getNumEdges();
// inserts a new vertex storing object O
public Vertex<V> insertVertex( V o );
// returns the edge object with specified endpoints
public Edge<V> findEdge(Vertex<V> u, Vertex<V> v) throws GraphException;
// true if u and v are adjacent, false otherwise
public boolean areAdjacent(Vertex<V> v, Vertex<V> u) throws GraphException;
// inserts an edge between u and v. Throws exception if edge is already there
// or u and v are the same vertx
public Edge<V> insertEdge(Vertex<V> v, Vertex<V> u) throws GraphException;
// deletes edge e
public void deleteEdge(Edge<V> e) throws GraphException;
// the endpoint of e other than v
public Vertex<V> giveOpposite(Vertex<V> v, Edge<V> e);
// iterator over vertice objects
public Iterator<Vertex<V>> vertices();
// iterator over edge objects
public Iterator<Edge<V>> edges();
}