Exemplo n.º 1
0
        public MaximalNonzeroEquivalenceClassRepresentativesResults <TVertex> ComputeMaximalNonzeroEquivalenceClassRepresentativesStartingAt <TVertex>(
            QuiverWithPotential <TVertex> qp,
            TVertex startingVertex,
            TransformationRuleTreeNode <TVertex> transformationRuleTree,
            QPAnalysisSettings settings)
            where TVertex : IEquatable <TVertex>, IComparable <TVertex>
        {
            var bogusPath       = new Path <TVertex>(qp.Quiver.Vertices.First());
            var analysisResults = AnalyzeWithStartingVertex(qp, startingVertex, transformationRuleTree, settings);
            var outputResults   = new MaximalNonzeroEquivalenceClassRepresentativesResults <TVertex>(
                analysisResults.NonCancellativityDetected ? CancellativityTypes.Cancellativity : CancellativityTypes.None,
                analysisResults.TooLongPathEncountered,
                analysisResults.MaximalPathRepresentatives.Select(node => node.Path),
                longestPathEncountered: bogusPath); // bogus path because this is an old method and the longest path feature is new

            return(outputResults);
        }
        /// <inheritdoc/>
        public MaximalNonzeroEquivalenceClassRepresentativesResults <TVertex> ComputeMaximalNonzeroEquivalenceClassRepresentativesStartingAt <TVertex>(
            Quiver <TVertex> quiver,
            TVertex startingVertex,
            TransformationRuleTreeNode <TVertex> transformationRuleTree,
            MaximalNonzeroEquivalenceClassRepresentativeComputationSettings settings)
            where TVertex : IEquatable <TVertex>, IComparable <TVertex>
        {
            var analysisResults = AnalyzeWithStartingVertex(quiver, startingVertex, transformationRuleTree, settings);

            // The .ToList() call to eagerly evaluate the maximal path representatives is really
            // important here; otherwise, the MaximalPathRepresentatives property of the
            // MaximalNonzeroEquivalenceClassRepresentativesResult prevents the entire search tree
            // of analysisResults from being freed.
            var maximalPathRepresentatives = analysisResults.MaximalPathRepresentatives.Select(node => node.Path).ToList();

            var outputResults = new MaximalNonzeroEquivalenceClassRepresentativesResults <TVertex>(
                analysisResults.CancellativityFailuresDetected,
                analysisResults.TooLongPathEncountered,
                maximalPathRepresentatives,
                analysisResults.LongestPathEncountered);

            return(outputResults);
        }