static protected void DoTest(JoinResolver solver) { // loop through all graph class for (int n = 2; n <= 9; n++) { JoinGraph graph; BigInteger expectC1; // expected nubmer are from section 6.9 expectC1 = (BigInteger.Pow(n, 3) - n) / 6; graph = new ClassChain().RandomGenerate(n); solver.Reset().Run(graph, expectC1); expectC1 = (BigInteger.Pow(n, 3) - (2 * BigInteger.Pow(n, 2)) + n) / 2; graph = new ClassCycle().RandomGenerate(n); solver.Reset().Run(graph, expectC1); expectC1 = BigInteger.Pow(2, n - 2) * (n - 1); graph = new ClassStar().RandomGenerate(n); solver.Reset().Run(graph, expectC1); expectC1 = (BigInteger.Pow(3, n) - BigInteger.Pow(2, n + 1) + 1) / 2; graph = new ClassClique().RandomGenerate(n); solver.Reset().Run(graph, expectC1); // no theoretic number graph = new ClassTree().RandomGenerate(n); solver.Reset().Run(graph); graph = new ClassRandom().RandomGenerate(n); solver.Reset().Run(graph); } }
static public void Test() { var solver = new TDBasic(); // loop through all graph class - can't use DPAlgorithm's DoTest() since the // expected numbers are not the same // for (int n = 2; n <= 10; n++) { JoinGraph graph; BigInteger expectC1; // expected nubmer are from Phd 2.2.4 - shall be the same as DPSub expectC1 = BigInteger.Pow(2, n + 2) - (n * n) - (3 * n) - 4; graph = new ClassChain().RandomGenerate(n); solver.Reset().Run(graph, expectC1); expectC1 = (1 + n) * BigInteger.Pow(2, n) - (2 * n * n) - 2; graph = new ClassCycle().RandomGenerate(n); solver.Reset().Run(graph, expectC1); expectC1 = (2 * BigInteger.Pow(3, n - 1)) - BigInteger.Pow(2, n); graph = new ClassStar().RandomGenerate(n); solver.Reset().Run(graph, expectC1); expectC1 = BigInteger.Pow(3, n) - BigInteger.Pow(2, n + 1) + 1; graph = new ClassClique().RandomGenerate(n); solver.Reset().Run(graph, expectC1); // no theoretic number graph = new ClassTree().RandomGenerate(n); solver.Reset().Run(graph); graph = new ClassRandom().RandomGenerate(n); solver.Reset().Run(graph); } }