Changeset 11750 for branches/HeuristicLab.EvolutionTracking
- Timestamp:
- 01/13/15 17:12:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/GenealogyGraph/GenealogyGraphNode.cs
r11459 r11750 59 59 } 60 60 61 public IEnumerable<IGenealogyGraphNode> Parents { 62 get { return InArcs.Select(a => a.Source); } 63 } 64 public IEnumerable<IGenealogyGraphNode> Children { 65 get { return OutArcs.Select(a => a.Target); } 66 } 67 61 68 public IEnumerable<IGenealogyGraphNode> Ancestors { 62 69 get { 70 if (!Parents.Any()) 71 return Enumerable.Empty<IGenealogyGraphNode>(); 63 72 // for performance, we use a hashset for lookup and a list for iteration 64 var nodes = new HashSet<IGenealogyGraphNode> { this };65 var list = new List<IGenealogyGraphNode> { this };73 var nodes = new HashSet<IGenealogyGraphNode>(Parents); 74 var list = new List<IGenealogyGraphNode>(Parents); 66 75 int i = 0; 67 76 while (i != list.Count) { … … 76 85 } 77 86 } 78 /// <summary> 79 /// Performs a downward-breath-traversal of the genealogy graph using the nodes OutArcs 80 /// </summary> 81 /// <returns>All the descendants of the current node</returns> 87 82 88 public IEnumerable<IGenealogyGraphNode> Descendants { 83 89 get { 84 var nodes = new HashSet<IGenealogyGraphNode> { this };85 var list = new List<IGenealogyGraphNode> { this };90 var nodes = new HashSet<IGenealogyGraphNode>(Children); 91 var list = new List<IGenealogyGraphNode>(Children); 86 92 int i = 0; 87 93 while (i != list.Count) { … … 96 102 } 97 103 } 104 98 105 [Storable] 99 106 public string Id { get; private set; } … … 119 126 public int CompareTo(IGenealogyGraphNode other) { 120 127 return Quality.CompareTo(other.Quality); 121 }122 public IEnumerable<IGenealogyGraphNode> Parents {123 get { return InArcs.Select(a => a.Source); }124 }125 public IEnumerable<IGenealogyGraphNode> Children {126 get { return OutArcs.Select(a => a.Target); }127 128 } 128 129 }
Note: See TracChangeset
for help on using the changeset viewer.