Esempio n. 1
0
        /// <summary>
        /// Analyzes a <see cref="QuiverInPlane{TVertex}"/>.
        /// </summary>
        /// <typeparam name="TVertex">The type of the vertices in the quiver.</typeparam>
        /// <param name="quiverInPlane">The quiver in plane to analyze.</param>
        /// <returns>The analysis results.</returns>
        /// <remarks>
        /// <para>If the analysis is unsuccessful, the value of the <c>MainResult</c> property
        /// of the returned analysis results does not have the
        /// <see cref="QuiverInPlaneAnalysisMainResults.Success"/> or the
        /// <see cref="QuiverInPlaneAnalysisMainResults.QPIsSelfInjective"/> flags set and has at least
        /// one of the other flags (each of which indicates some sort of failure) set. However, in
        /// the case of multiple causes for failure (e.g., the quiver has loops and anti-parallel
        /// arrows), all the corresponding flags are not necessarily set (e.g.,
        /// <see cref="QuiverInPlaneAnalysisMainResults.QuiverHasLoops"/> is set but
        /// <see cref="QuiverInPlaneAnalysisMainResults.QuiverHasAntiParallelArrows"/> is not set,
        /// or <see cref="QuiverInPlaneAnalysisMainResults.QuiverHasAntiParallelArrows"/> is set but
        /// <see cref="QuiverInPlaneAnalysisMainResults.QuiverHasLoops"/> is not set).</para>
        /// <para>This method does not throw any exceptions (unless I've forgotten something).</para>
        /// </remarks>
        public IQuiverInPlaneAnalysisResults <TVertex> Analyze <TVertex>(
            QuiverInPlane <TVertex> quiverInPlane,
            QuiverInPlaneAnalysisSettings settings)
            where TVertex : IEquatable <TVertex>, IComparable <TVertex>
        {
            if (quiverInPlane is null)
            {
                throw new ArgumentNullException(nameof(quiverInPlane));
            }

            var qpExtractor      = new QPExtractor();
            var extractionResult = qpExtractor.TryExtractQP(quiverInPlane, out var qp);

            if (extractionResult != QPExtractionResult.Success)
            {
                return(AnalysisResultsFactory.CreateQuiverInPlaneAnalysisResults <TVertex>(extractionResult));
            }

            var analyzer           = new QPAnalyzer();
            var qpAnalyzerSettings = AnalysisSettingsFactory.CreateQPAnalysisSettings(settings);
            var qpAnalysisResults  = analyzer.Analyze(qp, qpAnalyzerSettings);
            var analysisResults    = AnalysisResultsFactory.CreateQuiverInPlaneAnalysisResults(qpAnalysisResults);

            return(analysisResults);
        }
Esempio n. 2
0
        public static QPAnalysisSettings CreateQPAnalysisSettings(QuiverInPlaneAnalysisSettings settings)
        {
            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(new QPAnalysisSettings(
                       settings.CancellativityFailureDetection,
                       settings.MaxPathLength,
                       settings.EarlyTerminationConditions));
        }