-
Notifications
You must be signed in to change notification settings - Fork 1
/
GraphADT.java
107 lines (90 loc) · 2.96 KB
/
GraphADT.java
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package application;
import java.util.List;
import java.util.Set;
/**
* Filename: GraphADT.java
* Project: p4
* Authors: A-Team 70
*
* This interface is the basis for a graph that will be created(DO NOT edit this file)
*/
public interface GraphADT {
/**
* Add new vertex to the graph.
*
* If vertex is null or already exists, method ends without adding a vertex or throwing an
* exception.
*
* Valid argument conditions: 1. vertex is non-null 2. vertex is not already in the graph
*
* @param vertex the vertex to be added
*/
public void addVertex(String vertex);
/**
* Remove a vertex and all associated edges from the graph.
*
* If vertex is null or does not exist, method ends without removing a vertex, edges, or throwing
* an exception.
*
* Valid argument conditions: 1. vertex is non-null 2. vertex is not already in the graph
*
* @param vertex the vertex to be removed
*/
public void removeVertex(String vertex);
/**
* Add the edge from vertex1 to vertex2 to this graph. (edge is directed and unweighted)
*
* If either vertex does not exist, VERTEX IS ADDED and then edge is created. No exception is
* thrown.
*
* If the edge exists in the graph, no edge is added and no exception is thrown.
*
* Valid argument conditions: 1. neither vertex is null 2. both vertices are in the graph 3. the
* edge is not in the graph
*
* @param vertex1 the first vertex (src)
* @param vertex2 the second vertex (dst)
*/
public void addEdge(String vertex1, String vertex2);
/**
* Remove the edge from vertex1 to vertex2 from this graph. (edge is directed and unweighted) If
* either vertex does not exist, or if an edge from vertex1 to vertex2 does not exist, no edge is
* removed and no exception is thrown.
*
* Valid argument conditions: 1. neither vertex is null 2. both vertices are in the graph 3. the
* edge from vertex1 to vertex2 is in the graph
*
* @param vertex1 the first vertex
* @param vertex2 the second vertex
*/
public void removeEdge(String vertex1, String vertex2);
/**
* Returns a Set that contains all the vertices
*
* @return a Set<String> which contains all the vertices in the graph
*/
public List<String> getAllVertices();
/**
* Get all the friends (adjacent-dependencies) of a vertex
*
* For the example graph, A->[B, C], D->[A, B] getAdjacentVerticesOf(A) should return [B, C].
*
* In terms of users, this list contains the immediate friends of A.
*
* @param vertex the specified vertex
* @return an List<String> of all the adjacent vertices for specified vertex
*/
public List<String> getAdjacentVerticesOf(String vertex);
/**
* Returns the number of edges in this graph.
*
* @return number of edges in the graph.
*/
public int size();
/**
* Returns the number of vertices in this graph.
*
* @return number of vertices in graph.
*/
public int order();
}