Example #1
0
        public static DataStructures.Graph_AdjacencyList<Types.Vertex<int>, int> CreateTestGraph0()
        {
            DataStructures.Graph_AdjacencyList<Types.Vertex<int>, int> graph = new DataStructures.Graph_AdjacencyList<Types.Vertex<int>, int>(3);
            Types.Vertex<int> vertex0 = new Types.Vertex<int>(1, 0);
            Types.Vertex<int> vertex1 = new Types.Vertex<int>(2, 0);
            Types.Vertex<int> vertex2 = new Types.Vertex<int>(3, 0);

            graph.AddVertex(vertex0);
            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);

            graph.AddUndirectedEdge(vertex0, vertex1);
            graph.AddUndirectedEdge(vertex1, vertex2);
            graph.AddUndirectedEdge(vertex0, vertex2);

            Console.WriteLine("Original graph:\n" + graph.ToString());
            return graph;
        }
Example #2
0
        public static DataStructures.Graph_AdjacencyList<Types.Vertex<int>, int> CreateTestGraph1()
        {
            DataStructures.Graph_AdjacencyList<Types.Vertex<int>, int> graph = new DataStructures.Graph_AdjacencyList<Types.Vertex<int>, int>(4);
            Types.Vertex<int> vertex0 = new Types.Vertex<int>(0, 0);
            Types.Vertex<int> vertex1 = new Types.Vertex<int>(1, 0);
            Types.Vertex<int> vertex2 = new Types.Vertex<int>(2, 0);
            Types.Vertex<int> vertex3 = new Types.Vertex<int>(3, 0);
            Types.Vertex<int> vertex4 = new Types.Vertex<int>(4, 0);
            Types.Vertex<int> vertex5 = new Types.Vertex<int>(5, 0);
            Types.Vertex<int> vertex6 = new Types.Vertex<int>(6, 0);
            Types.Vertex<int> vertex7 = new Types.Vertex<int>(7, 0);

            graph.AddVertex(vertex0);
            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);
            graph.AddVertex(vertex4);
            graph.AddVertex(vertex5);
            graph.AddVertex(vertex6);
            graph.AddVertex(vertex7);

            graph.AddUndirectedEdge(vertex0, vertex1);
            graph.AddUndirectedEdge(vertex1, vertex2);
            graph.AddUndirectedEdge(vertex2, vertex3);
            graph.AddUndirectedEdge(vertex0, vertex3);
            graph.AddUndirectedEdge(vertex0, vertex2);
            graph.AddUndirectedEdge(vertex1, vertex3);
            graph.AddUndirectedEdge(vertex1, vertex4);
            //graph.AddUndirectedEdge(vertex1, vertex7);
            graph.AddUndirectedEdge(vertex2, vertex7);
            graph.AddUndirectedEdge(vertex4, vertex5);
            graph.AddUndirectedEdge(vertex5, vertex6);
            graph.AddUndirectedEdge(vertex6, vertex7);
            graph.AddUndirectedEdge(vertex4, vertex7);
            graph.AddUndirectedEdge(vertex4, vertex6);
            graph.AddUndirectedEdge(vertex5, vertex7);

            Console.WriteLine("Original graph:\n" + graph.ToString());
            return graph;
        }