Last change
on this file since 8479 was
8479,
checked in by spimming, 12 years ago
|
#1894:
- temporarily added weight and heuristic function to graph
- store category information and max speed with edge
- adapted Distance method
|
File size:
2.1 KB
|
Line | |
---|
1 |
|
---|
2 | namespace HeuristicLab.Problems.RoutePlanning.Graph {
|
---|
3 | public class Edge<Vertex> : IEdge<Vertex> {
|
---|
4 | private readonly Vertex source;
|
---|
5 | public Vertex Source {
|
---|
6 | get { return this.source; }
|
---|
7 | }
|
---|
8 |
|
---|
9 | private readonly Vertex target;
|
---|
10 | public Vertex Target {
|
---|
11 | get { return this.target; }
|
---|
12 | }
|
---|
13 |
|
---|
14 | private short category;
|
---|
15 | public short Category {
|
---|
16 | get { return category; }
|
---|
17 | set { category = value; }
|
---|
18 | }
|
---|
19 |
|
---|
20 | public Edge(Vertex source, Vertex target)
|
---|
21 | : this(source, target, 0) {
|
---|
22 |
|
---|
23 | }
|
---|
24 |
|
---|
25 | public Edge(Vertex source, Vertex target, short category) {
|
---|
26 | this.source = source;
|
---|
27 | this.target = target;
|
---|
28 | this.category = category;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public override string ToString() {
|
---|
32 | return string.Format("{0}->{1}", this.Source, this.Target);
|
---|
33 | }
|
---|
34 |
|
---|
35 | public override bool Equals(object obj) {
|
---|
36 | if (obj is Edge<Vertex>) {
|
---|
37 | Edge<Vertex> e = (obj as Edge<Vertex>);
|
---|
38 | return (this.source.Equals(e.source)) && (this.target.Equals(e.target));
|
---|
39 | }
|
---|
40 | return false;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public override int GetHashCode() {
|
---|
44 | return source.GetHashCode() ^ target.GetHashCode();
|
---|
45 | }
|
---|
46 |
|
---|
47 | public int GetMaxSpeed() {
|
---|
48 | int speed = 0;
|
---|
49 |
|
---|
50 | //TODO:
|
---|
51 | switch (category) {
|
---|
52 | case 23:
|
---|
53 | case 17:
|
---|
54 | case 18:
|
---|
55 | case 22:
|
---|
56 | case 21:
|
---|
57 | case 24:
|
---|
58 | case 0:
|
---|
59 | speed = 1;
|
---|
60 | break;
|
---|
61 |
|
---|
62 | case 20:
|
---|
63 | case 15:
|
---|
64 | case 12:
|
---|
65 | case 11:
|
---|
66 | speed = 15;
|
---|
67 | break;
|
---|
68 |
|
---|
69 | case 19:
|
---|
70 | case 16:
|
---|
71 | speed = 30;
|
---|
72 | break;
|
---|
73 |
|
---|
74 | case 9:
|
---|
75 | case 10:
|
---|
76 | case 7:
|
---|
77 | case 8:
|
---|
78 | speed = 80;
|
---|
79 | break;
|
---|
80 |
|
---|
81 | case 14:
|
---|
82 | case 13:
|
---|
83 | speed = 50;
|
---|
84 | break;
|
---|
85 |
|
---|
86 | case 3:
|
---|
87 | case 4:
|
---|
88 | case 5:
|
---|
89 | case 6:
|
---|
90 | speed = 100;
|
---|
91 | break;
|
---|
92 |
|
---|
93 | case 1:
|
---|
94 | case 2:
|
---|
95 | speed = 130;
|
---|
96 | break;
|
---|
97 |
|
---|
98 | default:
|
---|
99 | speed = 1;
|
---|
100 | break;
|
---|
101 | }
|
---|
102 | return speed;
|
---|
103 | }
|
---|
104 | }
|
---|
105 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.