/// <summary>
        /// Prompts the user for a QP.
        /// </summary>
        /// <param name="qp">Output parameter for the QP.</param>
        /// <param name="periods">Output parameter for the periods of the QP.</param>
        /// <param name="fixedPoint">Output parameter for the fixed-point of the QP (or
        /// <see langword="null"/> if there is none).</param>
        /// <returns><see langword="true"/> if the user specified a QP;
        /// <see langword="false"/> otherwise.</returns>
        private bool TryGetQP(
            out QuiverWithPotential <int> qp,
            out IEnumerable <IEnumerable <int> > periods,
            out int?fixedPoint)
        {
            if (!TryGetQPType(out var qpType) || !TryGetNumPeriods(qpType, out int numPeriods))
            {
                qp         = null;
                periods    = null;
                fixedPoint = null;
                return(false);
            }

            switch (qpType)
            {
            case QPType.OddFlower:
                qp         = UsefulQPs.GetOddFlowerQP(numPeriods, DefaultFirstVertex);
                periods    = UsefulQPs.GetPeriodsOfOddFlowerQP(numPeriods, DefaultFirstVertex);
                fixedPoint = null;
                break;

            case QPType.EvenFlowerType1:
                qp         = UsefulQPs.GetEvenFlowerType1QP(numPeriods, DefaultFirstVertex);
                periods    = UsefulQPs.GetPeriodsOfEvenFlowerType1QP(numPeriods, DefaultFirstVertex);
                fixedPoint = null;
                break;

            case QPType.EvenFlowerType2:
                qp         = UsefulQPs.GetEvenFlowerType2QP(numPeriods, DefaultFirstVertex);
                periods    = UsefulQPs.GetPeriodsOfEvenFlowerType2QP(numPeriods, DefaultFirstVertex);
                fixedPoint = null;
                break;

            case QPType.PointedFlower:
                qp      = UsefulQPs.GetPointedFlowerQP(numPeriods, DefaultFirstVertex);
                periods = UsefulQPs.GetPeriodsOfPointedFlowerQPWithoutFixedPoint(numPeriods, DefaultFirstVertex);
                throw new NotImplementedException();
                break;

            default:
                Debug.Fail($"Invalid QP type ({qpType}) specified.");
                qp         = null;
                periods    = null;
                fixedPoint = null;
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public void GetPeriodsOfEvenFlowerType1QP_Works(int numVerticesInCenterPolygon, int firstVertex, IEnumerable <IEnumerable <int> > expectedPeriods)
        {
            var actualPeriods = UsefulQPs.GetPeriodsOfEvenFlowerType1QP(numVerticesInCenterPolygon, firstVertex);

            Assert.That(actualPeriods, Is.EqualTo(expectedPeriods));
        }
Beispiel #3
0
 public void GetPeriodsOfEvenFlowerType1QP_ThrowsArgumentOutOfRangeException_OnBadNumberOfVerticesInCenterPolygon(int numVerticesInCenterPolygon, int firstVertex)
 {
     Assert.That(() => UsefulQPs.GetPeriodsOfEvenFlowerType1QP(numVerticesInCenterPolygon, firstVertex), Throws.InstanceOf <ArgumentOutOfRangeException>());
 }