src/GenFx/GeneticAlgorithm.cs
/// <summary>
/// Collects the roots of the set of graphs that make up the metric type dependencies.
/// </summary>
/// <param name="metricType">Type of <see cref="Metric"/> to process.</param>
/// <param name="roots">List of collected root nodes.</param>
/// <param name="collectedMetricTypes">Mapping of metric types and their nodes that have been collected so far.</param>
/// <returns>The <see cref="MetricNode"/> associated with <paramref name="metricType"/>.</returns>
Collects the roots of the set of graphs that make up the metric type dependencies.
Collects the roots of the set of graphs that make up the metric type dependencies .
private static MetricNode CollectMetricTypeGraphs(Type metricType, List<MetricNode> roots, Dictionary<Type, MetricNode> collectedMetricTypes)
        {
            if (collectedMetricTypes.TryGetValue(metricType, out MetricNode metricNode))
            {
                DetectMetricTypeDependencyCycle(metricNode, metricNode);
                return metricNode;
            }
            List<Type> metricTypeDependencies = GetMetricTypeDependencies(metricType);
            if (!metricTypeDependencies.Any())
            {
                MetricNode root = new MetricNode(metricType);
                roots.Add(root);
                metricNode = root;
                collectedMetricTypes.Add(metricType, metricNode);
            }
            else
            {
                MetricNode node = new MetricNode(metricType);
                collectedMetricTypes.Add(metricType, node);
                foreach (Type dependency in metricTypeDependencies)
                {
                    MetricNode dependencyNode = CollectMetricTypeGraphs(dependency, roots, collectedMetricTypes);
                    dependencyNode.Dependencies.Add(node);
                }
                metricNode = node;
            }
            return metricNode;
        }
private static MetricNode CollectMetricTypeGraphs ( Type metricType , List < MetricNode > roots , Dictionary < Type , MetricNode > collectedMetricTypes ) { if ( collectedMetricTypes . TryGetValue ( metricType , out MetricNode metricNode ) ) { DetectMetricTypeDependencyCycle ( metricNode , metricNode ) ; return metricNode ; } List < Type > metricTypeDependencies = GetMetricTypeDependencies ( metricType ) ; if ( ! metricTypeDependencies . Any ( ) ) { MetricNode root = new MetricNode ( metricType ) ; roots . Add ( root ) ; metricNode = root ; collectedMetricTypes . Add ( metricType , metricNode ) ; } else { MetricNode node = new MetricNode ( metricType ) ; collectedMetricTypes . Add ( metricType , node ) ; foreach ( Type dependency in metricTypeDependencies ) { MetricNode dependencyNode = CollectMetricTypeGraphs ( dependency , roots , collectedMetricTypes ) ; dependencyNode . Dependencies . Add ( node ) ; } metricNode = node ; } return metricNode ; }
Collects the roots of the set of graphs that make up the metric type dependencies.
Collects the roots of the set of graphs that make up the metric type dependencies .
// We've encountered a type that we've processed already.  Ensure that this isn't // the result of a cycle in the graph.
The  associated with .
The associated with .
metricType
Type
Type of  to process.
Type of to process .
roots
List<MetricNode>
List of collected root nodes.
List of collected root nodes .
collectedMetricTypes
Dictionary<Type, MetricNode>
Mapping of metric types and their nodes that have been collected so far.
Mapping of metric types and their nodes that have been collected so far .