Esempio n. 1
0
        public static void TestIsCycleInUnDirectedGraph()
        {
            UndirectedGraph udg = GraphProbHelper.CreateUndirectedGraphWithoutCycle();

            Console.WriteLine("Is the cycle present in the undirected graph: {0}", IsCycleInUnDirectedGraph(udg));

            udg = GraphProbHelper.CreateUndirectedGraphWithCycle();
            Console.WriteLine("Is the cycle present in the undirected graph: {0}", IsCycleInUnDirectedGraph(udg));
        }
Esempio n. 2
0
        public static void TestIsGraphATree()
        {
            IsGraphATree gt = new IsGraphATree();

            UndirectedGraph udg = GraphProbHelper.CreateUndirectedGraphWithoutCycleWithoutUnconnectedNodes();

            Console.WriteLine("Is the cycle present in the undirected graph: {0}", gt.IsGraphTree(udg));

            udg = GraphProbHelper.CreateUndirectedGraphWithoutCycle();
            Console.WriteLine("Is the cycle present in the undirected graph: {0}", gt.IsGraphTree(udg));

            udg = GraphProbHelper.CreateUndirectedGraphWithCycle();
            Console.WriteLine("Is the cycle present in the undirected graph: {0}", gt.IsGraphTree(udg));
        }
Esempio n. 3
0
        public static void TestCloneGraph()
        {
            UndirectedGraph udg = GraphProbHelper.CreateUndirectedGraphWithCycle();

            Console.WriteLine("The actual graph looks like:");
            GraphProbHelper.PrintGraphBFS(udg.AllVertices[0]);

            Console.WriteLine("The clone looks like");
            GraphVertex clone = Clone(udg.AllVertices[0]);

            GraphProbHelper.PrintGraphBFS(clone);

            DirectedGraph dg = GraphProbHelper.CreatedirectedGraphWithCycle();

            Console.WriteLine("The actual graph looks like:");
            GraphProbHelper.PrintGraphBFS(dg.AllVertices[0]);

            Console.WriteLine("The clone looks like");
            clone = Clone(dg.AllVertices[0]);
            GraphProbHelper.PrintGraphBFS(clone);
        }