Ejemplo n.º 1
0
        public override void VerifyTestCase(out Result resultCode, out string message, object settings)
        {
            if (cycle == null)
            {
                message    = "Nie zwrócono cyklu";
                resultCode = Result.BadResult;
                return;
            }

            if (!cycleChecker.Check(cycle, out message))
            {
                resultCode = Result.BadResult;
                return;
            }

            if (result != expectedResult)
            {
                message    = "Zly wynik, powinno byc: " + expectedResult + ", a jest: " + result + "\n";
                resultCode = Result.BadResult;
                return;
            }


            resultCode = Result.Success;
            message    = "OK";
        }
Ejemplo n.º 2
0
        public override void VerifyTestCase(out Result resultCode, out string message, object settings)
        {
            if (cycles == null)
            {
                message    = "Nie zwrócono wyniku";
                resultCode = Result.BadResult;
                return;
            }
            if (!AreEqual(g1, g) || !AreEqual(t1, t))
            {
                message    = "Zmodyfikowano grafy";
                resultCode = Result.BadResult;
                return;
            }
            Graph tLookup = new AdjacencyListsGraph <HashTableAdjacencyList>(t);
            Graph gLookup = new AdjacencyListsGraph <HashTableAdjacencyList>(g);
            var   test    = gLookup.Clone();

            foreach (var e in tLookup.GetEdges())
            {
                test.DelEdge(e);
            }
            foreach (var cycle in cycles)
            {
                bool   notInTree = false;
                bool[] vertices  = new bool[g.VerticesCount];
                if (!cycleChecker.Check(cycle, out message))
                {
                    resultCode = Result.BadResult;
                    return;
                }
                foreach (var e in cycle)
                {
                    if (!tLookup.ContainsEdge(e))
                    {
                        if (notInTree)
                        {
                            message    = "Wiele krawędzi spoza drzewa";
                            resultCode = Result.BadResult;
                            return;
                        }
                        notInTree = true;
                        if (!test.ContainsEdge(e))
                        {
                            message    = $"Wiele cykli z krawędzią {e}";
                            resultCode = Result.BadResult;
                            return;
                        }
                        test.DelEdge(e);
                    }
                }
            }
            if (test.EdgesCount != 0)
            {
                var e = test.GetEdges().First();
                message    = $"Brak cyklu z krawędzią {e}";
                resultCode = Result.BadResult;
                return;
            }
            resultCode = Result.Success;
            message    = "OK";
        }