|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.rblasch.convert.graph; |
|
17 |
| |
|
18 |
| import java.util.Iterator; |
|
19 |
| import java.util.LinkedList; |
|
20 |
| import java.util.List; |
|
21 |
| |
|
22 |
| public class ListPath implements Path { |
|
23 |
| private final List path; |
|
24 |
| |
|
25 |
602
| public ListPath(final List path) {
|
|
26 |
602
| this.path = path;
|
|
27 |
| } |
|
28 |
| |
|
29 |
2
| public Vertex getStart() {
|
|
30 |
2
| return (Vertex) path.get(0);
|
|
31 |
| } |
|
32 |
| |
|
33 |
2
| public Vertex getEnd() {
|
|
34 |
2
| return (Vertex) path.get(path.size() - 1);
|
|
35 |
| } |
|
36 |
| |
|
37 |
5
| public List getVertices() {
|
|
38 |
5
| final List vertices = new LinkedList();
|
|
39 |
5
| for (final Iterator i = path.iterator(); i.hasNext();) {
|
|
40 |
11
| final Object n = i.next();
|
|
41 |
11
| if (n instanceof Vertex) {
|
|
42 |
8
| vertices.add(n);
|
|
43 |
| } |
|
44 |
| } |
|
45 |
5
| return vertices;
|
|
46 |
| } |
|
47 |
| |
|
48 |
1138
| public List getEdges() {
|
|
49 |
1138
| final List edges = new LinkedList();
|
|
50 |
1138
| for (final Iterator i = path.iterator(); i.hasNext();) {
|
|
51 |
5502
| final Object n = i.next();
|
|
52 |
5502
| if (n instanceof Edge) {
|
|
53 |
2182
| edges.add(n);
|
|
54 |
| } |
|
55 |
| } |
|
56 |
1138
| return edges;
|
|
57 |
| } |
|
58 |
| |
|
59 |
2
| public Iterator iterator() {
|
|
60 |
2
| return path.iterator();
|
|
61 |
| } |
|
62 |
| } |