-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathGraph.java
More file actions
39 lines (25 loc) · 821 Bytes
/
Graph.java
File metadata and controls
39 lines (25 loc) · 821 Bytes
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 ssj.algorithm;
import com.google.common.base.Function;
import ssj.algorithm.collections.Vector;
import java.util.Iterator;
import java.util.function.Consumer;
/**
* Created by shenshijun on 15/2/7.
*/
public interface Graph<T> {
//TODO 实现有向图
void addEdge(T from, T to);
Iterator<T> nodes();
void dfs(Consumer<? super T> func);
<R> Vector<R> dfs(Function<? super T, ? extends R> func);
void bfs(Consumer<? super T> func);
<R> Vector<R> bfs(Function<? super T, ? extends R> func);
List<T> next(T ele);
void topologicalSort(Consumer<? super T> func);
<R> List<R> topologicalSort(Function<? super T, ? extends R> func);
int size();
public default boolean isEmpty() {
return size() <= 0;
}
List<T> shortestPath(T from, T to);
}