Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/DirectedGraph/Arc.cs @ 11238

Last change on this file since 11238 was 11238, checked in by bburlacu, 9 years ago

#2215: Updated interfaces and graph components according to the reviewer comments (IDirectedGraph, DirectedGraph, Vertex, Arc).

File size: 3.3 KB
RevLine 
[10278]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
[11229]22using System;
[10278]23using HeuristicLab.Common;
[10267]24using HeuristicLab.Core;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26
[11211]27namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
[10267]28  /// <summary>
[11229]29  /// An arc that can have a weight, a label, and a data object for holding additional info
[10267]30  /// </summary>
31  [StorableClass]
32  public class Arc : Item, IArc {
33    [Storable]
[11229]34    public IVertex Source { get; private set; }
[10897]35
[10267]36    [Storable]
[11229]37    public IVertex Target { get; private set; }
[10897]38
[10267]39    [Storable]
[11229]40    protected string label;
41    public string Label {
42      get { return label; }
43      set {
[11238]44        if (label.Equals(value)) return;
[11229]45        label = value;
46        OnChanged(this, EventArgs.Empty);
47      }
48    }
[10897]49
[10267]50    [Storable]
[11229]51    protected double weight;
52    public double Weight {
53      get { return weight; }
54      set {
[11238]55        if (weight.Equals(value)) return;
[11229]56        weight = value;
57        OnChanged(this, EventArgs.Empty);
58      }
59    }
[10897]60
[10267]61    [Storable]
[11229]62    protected object data;
63    public object Data {
64      get { return data; }
65      set {
[11238]66        if (data == value) return;
[11229]67        data = value;
68        OnChanged(this, EventArgs.Empty);
69      }
70    }
[10267]71
72    [StorableConstructor]
73    public Arc(bool deserializing) : base(deserializing) { }
74
[11229]75    public Arc(IVertex source, IVertex target) {
76      Source = source;
77      Target = target;
78    }
79
80    protected Arc(Arc original, Cloner cloner)
81      : base(original, cloner) {
82      Source = cloner.Clone(original.Source);
83      Target = cloner.Clone(original.Target);
84      label = original.Label;
85      weight = original.Weight;
86      data = original;
87    }
88
[10267]89    public override IDeepCloneable Clone(Cloner cloner) {
90      return new Arc(this, cloner);
91    }
[11238]92
93    public event EventHandler Changed;
94    protected virtual void OnChanged(object sender, EventArgs args) {
95      var changed = Changed;
96      if (changed != null)
97        changed(sender, args);
98    }
[11229]99  }
[10267]100
[11229]101  [StorableClass]
102  public class Arc<T> : Arc, IArc<T> where T : class,IItem {
103    public Arc(bool deserializing)
104      : base(deserializing) {
[10888]105    }
106
[11229]107    public Arc(IVertex source, IVertex target)
108      : base(source, target) {
109    }
110
[10267]111    protected Arc(Arc original, Cloner cloner)
112      : base(original, cloner) {
113    }
[11229]114
115    new public IVertex<T> Source {
116      get { return (IVertex<T>)base.Source; }
117    }
118    new public IVertex<T> Target {
119      get { return (IVertex<T>)base.Target; }
120    }
[10267]121  }
122}
Note: See TracBrowser for help on using the repository browser.