Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1894_RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/RoutingGraph/Edge.cs

Last change on this file was 8520, checked in by spimming, 12 years ago

#1894:

  • extended datasource interface to get routing graph for a specific vehicle type
  • use ICostCalculator to calculate edge weights
  • moved common enums in own file
  • removed method to estimate cost from graph; use ICostCalculator
File size: 1.4 KB
Line 
1
2using HeuristicLab.Problems.RoutePlanning.Interfaces;
3namespace HeuristicLab.Problems.RoutePlanning.RoutingGraph {
4  public class Edge<Vertex> : IEdge<Vertex> {
5    private readonly Vertex source;
6    public Vertex Source {
7      get { return this.source; }
8    }
9
10    private readonly Vertex target;
11    public Vertex Target {
12      get { return this.target; }
13    }
14
15    //private short category;
16    //public short Category {
17    //  get { return category; }
18    //  set { category = value; }
19    //}
20
21    private float weight;
22    public float Weight {
23      get { return weight; }
24      set { weight = value; }
25    }
26
27    public Edge(Vertex source, Vertex target)
28      : this(source, target, 0) {
29
30    }
31
32    public Edge(Vertex source, Vertex target, float weight) {
33      this.source = source;
34      this.target = target;
35      this.weight = weight;
36    }
37
38    public override string ToString() {
39      return string.Format("{0}->{1}", this.Source, this.Target);
40    }
41
42    public override bool Equals(object obj) {
43      if (obj is Edge<Vertex>) {
44        Edge<Vertex> e = (obj as Edge<Vertex>);
45        return (this.source.Equals(e.source)) && (this.target.Equals(e.target));
46      }
47      return false;
48    }
49
50    public override int GetHashCode() {
51      return source.GetHashCode() ^ target.GetHashCode();
52    }
53  }
54}
Note: See TracBrowser for help on using the repository browser.