[10884] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[12265] | 3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[10884] | 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 | */
|
---|
[12891] | 20 | #endregion License Information
|
---|
[10884] | 21 |
|
---|
[11390] | 22 | using System.Collections.Generic;
|
---|
[10884] | 23 | using System.Linq;
|
---|
[17434] | 24 | using HEAL.Attic;
|
---|
[10285] | 25 | using HeuristicLab.Common;
|
---|
[10278] | 26 | using HeuristicLab.Core;
|
---|
| 27 | using HeuristicLab.Data;
|
---|
[17434] | 28 | using HeuristicLab.EvolutionTracking;
|
---|
[10278] | 29 | using HeuristicLab.Operators;
|
---|
| 30 | using HeuristicLab.Optimization;
|
---|
| 31 | using HeuristicLab.Parameters;
|
---|
| 32 |
|
---|
[17434] | 33 | [Item("GenealogyAnalyzer", "An analyzer which performs the necessary instrumentation to record the evolution of a genetic algorithm.")]
|
---|
| 34 | [StorableType("04001C52-025C-4555-8812-AC3FA26A2B2F")]
|
---|
| 35 | public abstract class GenealogyAnalyzer<T> : SingleSuccessorOperator, IAnalyzer
|
---|
| 36 | where T : class, IItem
|
---|
| 37 | {
|
---|
| 38 | #region parameter names
|
---|
| 39 | private const string GenerationsParameterName = "Generations";
|
---|
| 40 | private const string ResultsParameterName = "Results";
|
---|
| 41 | private const string PopulationGraphParameterName = "PopulationGraph";
|
---|
| 42 | public const string QualityParameterName = "Quality";
|
---|
| 43 | public const string PopulationParameterName = "SymbolicExpressionTree";
|
---|
[10278] | 44 |
|
---|
[17434] | 45 | private const string CrossoverParameterName = "Crossover";
|
---|
| 46 | private const string ManipulatorParameterName = "Mutator";
|
---|
| 47 | private const string SolutionCreatorParameterName = "SolutionCreator";
|
---|
[10278] | 48 |
|
---|
[17434] | 49 | private const string BeforeCrossoverOperatorParameterName = "BeforeCrossoverOperator";
|
---|
| 50 | private const string AfterCrossoverOperatorParameterName = "AfterCrossoverOperator";
|
---|
[10830] | 51 |
|
---|
[17434] | 52 | private const string BeforeManipulatorOperatorParameterName = "BeforeManipulatorOperator";
|
---|
| 53 | private const string AfterManipulatorOperatorParameterName = "AfterManipulatorOperator";
|
---|
[10830] | 54 |
|
---|
[17434] | 55 | private const string EnableCrossoverTrackingParameterName = "EnableCrossoverTracking";
|
---|
| 56 | private const string EnableManipulatorTrackingParameterName = "EnableManipulatorTracking";
|
---|
| 57 | private const string EnableSolutionCreatorTrackingParameterName = "EnableSolutionCreatorTracking"; // should always be enabled. maybe superfluous
|
---|
| 58 | private const string TrimOlderGenerationsParameterName = "TrimOlderGenerations";
|
---|
| 59 | #endregion parameter names
|
---|
[10278] | 60 |
|
---|
[17434] | 61 | #region parameter properties
|
---|
[12951] | 62 |
|
---|
[17434] | 63 | public IFixedValueParameter<BoolValue> TrimOlderGenerationsParameter {
|
---|
| 64 | get { return (IFixedValueParameter<BoolValue>)Parameters[TrimOlderGenerationsParameterName]; }
|
---|
| 65 | }
|
---|
[12951] | 66 |
|
---|
[17434] | 67 | public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
|
---|
| 68 | get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters[QualityParameterName]; }
|
---|
| 69 | }
|
---|
[12891] | 70 |
|
---|
[17434] | 71 | public IScopeTreeLookupParameter<T> PopulationParameter {
|
---|
| 72 | get { return (IScopeTreeLookupParameter<T>)Parameters[PopulationParameterName]; }
|
---|
| 73 | }
|
---|
[12891] | 74 |
|
---|
[17434] | 75 | public IValueParameter<ICrossoverOperator<T>> BeforeCrossoverOperatorParameter {
|
---|
| 76 | get { return (IValueParameter<ICrossoverOperator<T>>)Parameters[BeforeCrossoverOperatorParameterName]; }
|
---|
| 77 | }
|
---|
[12891] | 78 |
|
---|
[17434] | 79 | public IValueParameter<ICrossoverOperator<T>> AfterCrossoverOperatorParameter {
|
---|
| 80 | get { return (IValueParameter<ICrossoverOperator<T>>)Parameters[AfterCrossoverOperatorParameterName]; }
|
---|
| 81 | }
|
---|
[12891] | 82 |
|
---|
[17434] | 83 | public IValueParameter<IManipulatorOperator<T>> BeforeManipulatorOperatorParameter {
|
---|
| 84 | get { return (IValueParameter<IManipulatorOperator<T>>)Parameters[BeforeManipulatorOperatorParameterName]; }
|
---|
| 85 | }
|
---|
[12891] | 86 |
|
---|
[17434] | 87 | public IValueParameter<IManipulatorOperator<T>> AfterManipulatorOperatorParameter {
|
---|
| 88 | get { return (IValueParameter<IManipulatorOperator<T>>)Parameters[AfterManipulatorOperatorParameterName]; }
|
---|
| 89 | }
|
---|
[12891] | 90 |
|
---|
[17434] | 91 | public ILookupParameter<ResultCollection> ResultsParameter {
|
---|
| 92 | get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
|
---|
| 93 | }
|
---|
[12891] | 94 |
|
---|
[17434] | 95 | public ILookupParameter<IntValue> GenerationsParameter {
|
---|
| 96 | get { return (ILookupParameter<IntValue>)Parameters[GenerationsParameterName]; }
|
---|
| 97 | }
|
---|
[12891] | 98 |
|
---|
[17434] | 99 | public IValueParameter<BoolValue> EnableCrossoverTrackingParameter {
|
---|
| 100 | get { return (IValueParameter<BoolValue>)Parameters[EnableCrossoverTrackingParameterName]; }
|
---|
| 101 | }
|
---|
[12891] | 102 |
|
---|
[17434] | 103 | public IValueParameter<BoolValue> EnableManipulatorTrackingParameter {
|
---|
| 104 | get { return (IValueParameter<BoolValue>)Parameters[EnableManipulatorTrackingParameterName]; }
|
---|
| 105 | }
|
---|
[12891] | 106 |
|
---|
[17434] | 107 | public IValueParameter<BoolValue> EnableSolutionCreatorTrackingParameter {
|
---|
| 108 | get { return (IValueParameter<BoolValue>)Parameters[EnableSolutionCreatorTrackingParameterName]; }
|
---|
| 109 | }
|
---|
[12891] | 110 |
|
---|
[17434] | 111 | public ILookupParameter<ICrossover> CrossoverParameter {
|
---|
| 112 | get { return (ILookupParameter<ICrossover>)Parameters[CrossoverParameterName]; }
|
---|
| 113 | }
|
---|
[12891] | 114 |
|
---|
[17434] | 115 | public ILookupParameter<IManipulator> ManipulatorParameter {
|
---|
| 116 | get { return (ILookupParameter<IManipulator>)Parameters[ManipulatorParameterName]; }
|
---|
| 117 | }
|
---|
[10830] | 118 |
|
---|
[17434] | 119 | public ILookupParameter<ISolutionCreator> SolutionCreatorParameter {
|
---|
| 120 | get { return (ILookupParameter<ISolutionCreator>)Parameters[SolutionCreatorParameterName]; }
|
---|
| 121 | }
|
---|
| 122 | #endregion parameter properties
|
---|
[10278] | 123 |
|
---|
[17434] | 124 | #region properties
|
---|
| 125 | public ICrossoverOperator<T> BeforeCrossoverOperator {
|
---|
| 126 | get { return BeforeCrossoverOperatorParameter.Value; }
|
---|
| 127 | }
|
---|
[12891] | 128 |
|
---|
[17434] | 129 | public ICrossoverOperator<T> AfterCrossoverOperator {
|
---|
| 130 | get { return AfterCrossoverOperatorParameter.Value; }
|
---|
| 131 | }
|
---|
[12891] | 132 |
|
---|
[17434] | 133 | public IManipulatorOperator<T> BeforeManipulatorOperator {
|
---|
| 134 | get { return BeforeManipulatorOperatorParameter.Value; }
|
---|
| 135 | }
|
---|
[12891] | 136 |
|
---|
[17434] | 137 | public IManipulatorOperator<T> AfterManipulatorOperator {
|
---|
| 138 | get { return AfterManipulatorOperatorParameter.Value; }
|
---|
| 139 | }
|
---|
[12891] | 140 |
|
---|
[17434] | 141 | public BoolValue EnableCrossoverTracking {
|
---|
| 142 | get { return EnableCrossoverTrackingParameter.Value; }
|
---|
| 143 | }
|
---|
[12891] | 144 |
|
---|
[17434] | 145 | public BoolValue EnableManipulatorTracking {
|
---|
| 146 | get { return EnableManipulatorTrackingParameter.Value; }
|
---|
| 147 | }
|
---|
[12891] | 148 |
|
---|
[17434] | 149 | public BoolValue EnableSolutionCreatorTracking {
|
---|
| 150 | get { return EnableSolutionCreatorTrackingParameter.Value; }
|
---|
| 151 | }
|
---|
[12951] | 152 |
|
---|
[17434] | 153 | public bool TrimOlderGenerations {
|
---|
| 154 | get { return TrimOlderGenerationsParameter.Value.Value; }
|
---|
| 155 | }
|
---|
| 156 | #endregion properties
|
---|
[10278] | 157 |
|
---|
[17434] | 158 | protected GenealogyAnalyzer() {
|
---|
| 159 | #region add parameters
|
---|
| 160 | // the instrumented operators
|
---|
| 161 | Parameters.Add(new LookupParameter<ICrossover>(CrossoverParameterName, "The crossover operator."));
|
---|
| 162 | Parameters.Add(new LookupParameter<IManipulator>(ManipulatorParameterName, "The manipulator operator."));
|
---|
| 163 | Parameters.Add(new LookupParameter<ISolutionCreator>(SolutionCreatorParameterName, "The solution creator operator."));
|
---|
| 164 | // the analyzer parameters
|
---|
| 165 | Parameters.Add(new ValueParameter<BoolValue>(EnableCrossoverTrackingParameterName, new BoolValue(true)));
|
---|
| 166 | Parameters.Add(new ValueParameter<BoolValue>(EnableManipulatorTrackingParameterName, new BoolValue(true)));
|
---|
| 167 | Parameters.Add(new ValueParameter<BoolValue>(EnableSolutionCreatorTrackingParameterName, new BoolValue(true)));
|
---|
| 168 | // parameters required by the analyzer to do its work
|
---|
| 169 | Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName, "The number of generations so far."));
|
---|
| 170 | Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName));
|
---|
| 171 | Parameters.Add(new ScopeTreeLookupParameter<T>(PopulationParameterName, "The population of individuals."));
|
---|
| 172 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "The individual qualities."));
|
---|
| 173 | Parameters.Add(new ValueParameter<ICrossoverOperator<T>>(BeforeCrossoverOperatorParameterName));
|
---|
| 174 | Parameters.Add(new ValueParameter<ICrossoverOperator<T>>(AfterCrossoverOperatorParameterName));
|
---|
| 175 | Parameters.Add(new ValueParameter<IManipulatorOperator<T>>(BeforeManipulatorOperatorParameterName));
|
---|
| 176 | Parameters.Add(new ValueParameter<IManipulatorOperator<T>>(AfterManipulatorOperatorParameterName));
|
---|
| 177 | Parameters.Add(new FixedValueParameter<BoolValue>(TrimOlderGenerationsParameterName, "Remove all the generations older than the last generation from the genealoy graph to save memory."));
|
---|
| 178 | #endregion add parameters
|
---|
| 179 | }
|
---|
| 180 |
|
---|
| 181 | protected GenealogyAnalyzer(GenealogyAnalyzer<T> original, Cloner cloner)
|
---|
| 182 | : base(original, cloner) {
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | [StorableConstructor]
|
---|
| 186 | protected GenealogyAnalyzer(StorableConstructorFlag _) : base(_) { }
|
---|
| 187 |
|
---|
| 188 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 189 | private void AfterDeserialization() {
|
---|
| 190 | // the instrumented operators
|
---|
| 191 | if (!Parameters.ContainsKey(CrossoverParameterName))
|
---|
[10278] | 192 | Parameters.Add(new LookupParameter<ICrossover>(CrossoverParameterName, "The crossover operator."));
|
---|
[17434] | 193 | if (!Parameters.ContainsKey(ManipulatorParameterName))
|
---|
[10278] | 194 | Parameters.Add(new LookupParameter<IManipulator>(ManipulatorParameterName, "The manipulator operator."));
|
---|
[17434] | 195 | if (!Parameters.ContainsKey(SolutionCreatorParameterName))
|
---|
[10278] | 196 | Parameters.Add(new LookupParameter<ISolutionCreator>(SolutionCreatorParameterName, "The solution creator operator."));
|
---|
[17434] | 197 | // the analyzer parameters
|
---|
| 198 | if (!Parameters.ContainsKey(EnableCrossoverTrackingParameterName))
|
---|
[10278] | 199 | Parameters.Add(new ValueParameter<BoolValue>(EnableCrossoverTrackingParameterName, new BoolValue(true)));
|
---|
[17434] | 200 | if (!Parameters.ContainsKey(EnableManipulatorTrackingParameterName))
|
---|
[10278] | 201 | Parameters.Add(new ValueParameter<BoolValue>(EnableManipulatorTrackingParameterName, new BoolValue(true)));
|
---|
[17434] | 202 | if (!Parameters.ContainsKey(EnableSolutionCreatorTrackingParameterName))
|
---|
[10278] | 203 | Parameters.Add(new ValueParameter<BoolValue>(EnableSolutionCreatorTrackingParameterName, new BoolValue(true)));
|
---|
[17434] | 204 | // parameters required by the analyzer to do its work
|
---|
| 205 | if (!Parameters.ContainsKey(GenerationsParameterName))
|
---|
[10278] | 206 | Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName, "The number of generations so far."));
|
---|
[17434] | 207 | if (!Parameters.ContainsKey(ResultsParameterName))
|
---|
[10278] | 208 | Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName));
|
---|
[17434] | 209 | if (!Parameters.ContainsKey(PopulationParameterName)) {
|
---|
[10830] | 210 | Parameters.Add(new ScopeTreeLookupParameter<T>(PopulationParameterName, "The population of individuals."));
|
---|
[17434] | 211 | }
|
---|
| 212 | if (!Parameters.ContainsKey(QualityParameterName)) {
|
---|
[10830] | 213 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "The individual qualities."));
|
---|
[17434] | 214 | }
|
---|
| 215 | if (!Parameters.ContainsKey(TrimOlderGenerationsParameterName))
|
---|
[12951] | 216 | Parameters.Add(new FixedValueParameter<BoolValue>(TrimOlderGenerationsParameterName, "Remove all the generations older than the last generation from the genealoy graph to save memory."));
|
---|
[17434] | 217 | }
|
---|
[12891] | 218 |
|
---|
[17434] | 219 | public bool EnabledByDefault {
|
---|
| 220 | get { return false; }
|
---|
| 221 | }
|
---|
[11227] | 222 |
|
---|
[17434] | 223 | private void ConfigureTrackingOperators() {
|
---|
| 224 | // at the beginning we add the before/after operators to the instrumented operators
|
---|
| 225 | var crossover = CrossoverParameter.ActualValue;
|
---|
| 226 | if (crossover != null) {
|
---|
| 227 | var instrumentedCrossover = (InstrumentedOperator)crossover;
|
---|
| 228 | instrumentedCrossover.AfterExecutionOperators.Clear();
|
---|
| 229 | instrumentedCrossover.BeforeExecutionOperators.Clear();
|
---|
[11227] | 230 |
|
---|
[17434] | 231 | if (EnableCrossoverTracking.Value) {
|
---|
| 232 | if (BeforeCrossoverOperator != null) {
|
---|
| 233 | instrumentedCrossover.BeforeExecutionOperators.Add(BeforeCrossoverOperator);
|
---|
| 234 | }
|
---|
| 235 | if (AfterCrossoverOperator != null) {
|
---|
| 236 | instrumentedCrossover.AfterExecutionOperators.Add(AfterCrossoverOperator);
|
---|
| 237 | }
|
---|
[10347] | 238 | }
|
---|
| 239 | }
|
---|
[17434] | 240 | var manipulator = ManipulatorParameter.ActualValue;
|
---|
| 241 | if (manipulator != null) {
|
---|
| 242 | var instrumentedManipulator = (InstrumentedOperator)manipulator;
|
---|
| 243 | instrumentedManipulator.AfterExecutionOperators.Clear();
|
---|
| 244 | instrumentedManipulator.BeforeExecutionOperators.Clear();
|
---|
[10278] | 245 |
|
---|
[17434] | 246 | if (EnableManipulatorTracking.Value) {
|
---|
| 247 | if (BeforeManipulatorOperator != null) {
|
---|
| 248 | instrumentedManipulator.BeforeExecutionOperators.Add(BeforeManipulatorOperator);
|
---|
[10285] | 249 | }
|
---|
[17434] | 250 | if (AfterManipulatorOperator != null) {
|
---|
| 251 | instrumentedManipulator.AfterExecutionOperators.Add(AfterManipulatorOperator);
|
---|
[10285] | 252 | }
|
---|
[10462] | 253 | }
|
---|
| 254 | }
|
---|
[17434] | 255 | }
|
---|
[10462] | 256 |
|
---|
[17434] | 257 | protected abstract void EvaluateIntermediateChildren();
|
---|
[12892] | 258 |
|
---|
[17434] | 259 | public override IOperation Apply() {
|
---|
| 260 | IGenealogyGraph<T> genealogyGraph;
|
---|
| 261 | var results = ResultsParameter.ActualValue;
|
---|
| 262 | if (!results.ContainsKey(PopulationGraphParameterName)) {
|
---|
| 263 | genealogyGraph = new GenealogyGraph<T>();
|
---|
| 264 | results.Add(new Result(PopulationGraphParameterName, genealogyGraph));
|
---|
| 265 | } else {
|
---|
| 266 | genealogyGraph = (IGenealogyGraph<T>)results[PopulationGraphParameterName].Value;
|
---|
| 267 | }
|
---|
[11390] | 268 |
|
---|
[17434] | 269 | var population = PopulationParameter.ActualValue;
|
---|
| 270 | var qualities = QualityParameter.ActualValue;
|
---|
[10462] | 271 |
|
---|
[17434] | 272 | int generation = GenerationsParameter.ActualValue.Value;
|
---|
| 273 | if (generation == 0) {
|
---|
| 274 | ConfigureTrackingOperators();
|
---|
[10462] | 275 |
|
---|
[17434] | 276 | for (int i = 0; i < population.Length; ++i) {
|
---|
| 277 | var individual = population[i];
|
---|
| 278 | var vertex = new GenealogyGraphNode<T>(individual) { Rank = generation };
|
---|
| 279 | genealogyGraph.AddVertex(vertex);
|
---|
| 280 | // save the vertex id in the individual scope (so that we can identify graph indices)
|
---|
| 281 | ExecutionContext.Scope.SubScopes[i].Variables.Add(new Variable("Id", new StringValue(vertex.Id)));
|
---|
[10278] | 282 | }
|
---|
[17434] | 283 | } else {
|
---|
| 284 | int index = 0;
|
---|
| 285 | T elite = null;
|
---|
| 286 | // identify previous elite individual
|
---|
[11227] | 287 | for (int i = 0; i < population.Length; ++i) {
|
---|
[17434] | 288 | if (genealogyGraph.GetByContent(population[i]).Rank.Equals(generation - 1)) {
|
---|
| 289 | elite = population[i];
|
---|
| 290 | index = i;
|
---|
| 291 | break;
|
---|
[11390] | 292 | }
|
---|
| 293 | }
|
---|
[17434] | 294 | // add current elite and connect with previous
|
---|
| 295 | #region add elite in the graph and connect it with the previous elite
|
---|
| 296 | if (elite != null) {
|
---|
| 297 | var prevVertex = genealogyGraph.GetByContent(elite);
|
---|
| 298 | prevVertex.IsElite = true; // mark elites in the graph retroactively
|
---|
| 299 | var v = (IGenealogyGraphNode<T>)prevVertex.Clone();
|
---|
| 300 | v.Rank = generation;
|
---|
| 301 | v.IsElite = false;
|
---|
| 302 | population[index] = v.Data;
|
---|
| 303 | genealogyGraph.AddVertex(v);
|
---|
| 304 | genealogyGraph.AddArc(prevVertex, v);
|
---|
| 305 | // inject the graph node unique id to the scope
|
---|
| 306 | ExecutionContext.Scope.SubScopes[index].Variables[BeforeManipulatorOperator.ChildParameter.ActualName].Value = v.Data;
|
---|
| 307 | ExecutionContext.Scope.SubScopes[index].Variables["Id"].Value = new StringValue(v.Id);
|
---|
| 308 | }
|
---|
| 309 | #endregion add elite in the graph and connect it with the previous elite
|
---|
| 310 | }
|
---|
| 311 | // update qualities
|
---|
| 312 | for (int i = 0; i < population.Length; ++i) {
|
---|
| 313 | var vertex = genealogyGraph.GetByContent(population[i]);
|
---|
| 314 | vertex.Quality = qualities[i].Value;
|
---|
| 315 | }
|
---|
| 316 | // update qualities for intermediate vertices
|
---|
| 317 | EvaluateIntermediateChildren();
|
---|
[11257] | 318 |
|
---|
[17434] | 319 | // remove extra graph nodes (added by the instrumented operators in the case of offspring selection)
|
---|
| 320 | var pop = new HashSet<T>(population);
|
---|
| 321 | var discarded = genealogyGraph.GetByRank(generation).Where(x => !pop.Contains(x.Data)).ToList();
|
---|
| 322 | for (int i = 0; i < discarded.Count; ++i) {
|
---|
| 323 | var v = discarded[i];
|
---|
| 324 | if (v.InDegree == 1) {
|
---|
| 325 | var p = v.Parents.First();
|
---|
| 326 | if (p.Rank.Equals(generation - 0.5))
|
---|
| 327 | // the individual was a product of mutation. since it wasn't selected, we must remove both it and its parent
|
---|
| 328 | // ("intermediate" vertex result of crossover)
|
---|
| 329 | discarded.Add(v.Parents.First());
|
---|
[12951] | 330 | }
|
---|
[17434] | 331 | }
|
---|
| 332 | genealogyGraph.RemoveVertices(discarded);
|
---|
[12951] | 333 |
|
---|
[17434] | 334 | //trim
|
---|
| 335 | if (TrimOlderGenerations) {
|
---|
| 336 | var vertices = genealogyGraph.Vertices.Where(x => x.Rank < generation - 1).ToList(); // select all ranks older than the previous generation
|
---|
| 337 | genealogyGraph.RemoveVertices(vertices);
|
---|
[11257] | 338 | }
|
---|
[17434] | 339 |
|
---|
| 340 | return base.Apply();
|
---|
[10278] | 341 | }
|
---|
[17434] | 342 | }
|
---|