/// <summary> /// /// </summary> /// <param name="numRows">The number of rows of vertices.</param> /// <param name="firstVertex"></param> /// <returns></returns> public static QuiverWithPotential <int> GetSquareQP(int numRows, int firstVertex = DefaultFirstVertex) { if (!SquareParameterIsValid(numRows)) { throw new ArgumentOutOfRangeException(nameof(numRows)); } int numVerticesInRow = numRows; int numVertices = numVerticesInRow * numRows; if (numRows == 1) { var quiver = UsefulQuivers.GetSquareQuiver(numRows, firstVertex); return(new QuiverWithPotential <int>(quiver, new Potential <int>())); } var potential = new Potential <int>(); for (int rowIndex = 0; rowIndex < numRows - 1; rowIndex++) { var curRow = GetVerticesInSquareQPRow(numRows, rowIndex, firstVertex).ToList(); var nextRow = GetVerticesInSquareQPRow(numRows, rowIndex + 1, firstVertex).ToList(); for (int indexInRow = 0; indexInRow < numVerticesInRow - 1; indexInRow++) { int sign = (rowIndex + indexInRow).Modulo(2) == 0 ? +1 : -1; var cycleVertices = sign == +1 ? new int[] { curRow[indexInRow], curRow[indexInRow + 1], nextRow[indexInRow + 1], nextRow[indexInRow], curRow[indexInRow] } : new int[] { curRow[indexInRow + 1], curRow[indexInRow], nextRow[indexInRow], nextRow[indexInRow + 1], curRow[indexInRow + 1] }; potential = potential.AddCycle(new DetachedCycle <int>(cycleVertices), sign); } } var qp = new QuiverWithPotential <int>(potential); return(qp); }