-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.java
More file actions
39 lines (29 loc) · 715 Bytes
/
Graph.java
File metadata and controls
39 lines (29 loc) · 715 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 core;
import java.util.ArrayList;
import java.util.List;
//图包括节点和边,其中边的名字如果为 '&'则表示空串
public class Graph {
private List<Node> nodes = new ArrayList<Node>();
private List<Edge> edges = new ArrayList<Edge>();
public List<Edge> getEdges() {
return edges;
}
public List<Node> getNodes() {
return nodes;
}
public void setEdges(List<Edge> edges) {
this.edges = edges;
}
public void setNodes(List<Node> nodes) {
this.nodes = nodes;
}
// 根据index找到相应的Node
public Node getNodeById(int index) {
for (int i = 0; i < getNodes().size(); i++) {
if (getNodes().get(i).getIndex() == index) {
return getNodes().get(i).clone();
}
}
return null;
}
}