Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/29/14 16:20:08 (10 years ago)
Author:
bburlacu
Message:

#2215: Refactored and simplified DirectedGraph and related components API, simplified the BottomUpSimilarityCalculator by not using a directed graph and vertices but a simpler object so that the similarity calculator is self-contained.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/DirectedGraph/Arc.cs

    r11211 r11229  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2728  /// <summary>
    28   /// An arc that can have a weight, a label, and can old additional information in the Data object
     29  /// An arc that can have a weight, a label, and a data object for holding additional info
    2930  /// </summary>
    3031  [StorableClass]
    3132  public class Arc : Item, IArc {
    32     [Storable]
    33     public IVertex Source { get; set; }
     33    public event EventHandler Changed;
     34    protected virtual void OnChanged(object sender, EventArgs args) {
     35      var changed = Changed;
     36      if (changed != null)
     37        changed(sender, args);
     38    }
    3439
    3540    [Storable]
    36     public IVertex Target { get; set; }
     41    public IVertex Source { get; private set; }
    3742
    3843    [Storable]
    39     public string Label { get; set; }
     44    public IVertex Target { get; private set; }
    4045
    4146    [Storable]
    42     public double Weight { get; set; }
     47    protected string label;
     48    public string Label {
     49      get { return label; }
     50      set {
     51        label = value;
     52        OnChanged(this, EventArgs.Empty);
     53      }
     54    }
    4355
    4456    [Storable]
    45     public object Data { get; set; }
     57    protected double weight;
     58    public double Weight {
     59      get { return weight; }
     60      set {
     61        weight = value;
     62        OnChanged(this, EventArgs.Empty);
     63      }
     64    }
     65
     66    [Storable]
     67    protected object data;
     68    public object Data {
     69      get { return data; }
     70      set {
     71        data = value;
     72        OnChanged(this, EventArgs.Empty);
     73      }
     74    }
    4675
    4776    [StorableConstructor]
    4877    public Arc(bool deserializing) : base(deserializing) { }
    49 
    50     public override IDeepCloneable Clone(Cloner cloner) {
    51       return new Arc(this, cloner);
    52     }
    53     public Arc() { }
    5478
    5579    public Arc(IVertex source, IVertex target) {
     
    6084    protected Arc(Arc original, Cloner cloner)
    6185      : base(original, cloner) {
    62       Source = original.Source;
    63       Target = original.Target;
    64       Label = original.Label;
    65       Weight = original.Weight;
    66       Data = original.Data;
     86      Source = cloner.Clone(original.Source);
     87      Target = cloner.Clone(original.Target);
     88      label = original.Label;
     89      weight = original.Weight;
     90      data = original;
     91    }
     92
     93    public override IDeepCloneable Clone(Cloner cloner) {
     94      return new Arc(this, cloner);
     95    }
     96  }
     97
     98  [StorableClass]
     99  public class Arc<T> : Arc, IArc<T> where T : class,IItem {
     100    public Arc(bool deserializing)
     101      : base(deserializing) {
     102    }
     103
     104    public Arc(IVertex source, IVertex target)
     105      : base(source, target) {
     106    }
     107
     108    protected Arc(Arc original, Cloner cloner)
     109      : base(original, cloner) {
     110    }
     111
     112    new public IVertex<T> Source {
     113      get { return (IVertex<T>)base.Source; }
     114    }
     115    new public IVertex<T> Target {
     116      get { return (IVertex<T>)base.Target; }
    67117    }
    68118  }
Note: See TracChangeset for help on using the changeset viewer.