Ignore:
Timestamp:
08/04/14 14:58:47 (8 years ago)
Author:
bburlacu
Message:

#2223:

  • Vertex: remove cloning of arcs in the cloning constructor
  • DirectedGraph; Adjust cloning constructor to add arcs to cloned vertices
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/Collections/DirectedGraph/Vertex.cs

    r11248 r11263  
    9393      weight = original.Weight;
    9494
    95       inArcs = original.InArcs.Select(cloner.Clone).ToList();
    96       outArcs = original.OutArcs.Select(cloner.Clone).ToList();
     95      // we do not clone the arcs here (would cause too much recursion and ultimately a stack overflow)
    9796    }
    9897
     
    103102    public void AddArc(IArc arc) {
    104103      if (this != arc.Source && this != arc.Target)
    105         throw new InvalidOperationException("The current vertex must be either the arc source or the arc target.");
     104        throw new ArgumentException("The current vertex must be either the arc source or the arc target.");
     105
     106      if (arc.Source == arc.Target)
     107        throw new ArgumentException("Arc source and target must be different.");
    106108
    107109      if (this == arc.Source) {
     
    118120    public void RemoveArc(IArc arc) {
    119121      if (this != arc.Source && this != arc.Target)
    120         throw new InvalidOperationException("The current vertex must be either the arc source or the arc target.");
     122        throw new ArgumentException("The current vertex must be either the arc source or the arc target.");
    121123
    122124      if (this == arc.Source) {
     
    168170    }
    169171
     172    public Vertex(IDeepCloneable data)
     173      : base(data) {
     174    }
     175
    170176    public override IDeepCloneable Clone(Cloner cloner) {
    171177      return new Vertex<T>(this, cloner);
Note: See TracChangeset for help on using the changeset viewer.