示例#1
0
        private static void TestMatrixStuff()
        {
            Graph g = new Graph();
            g.Directed = true;
            Vertex v1 = new Vertex();
            Vertex v2 = new Vertex();
            Vertex v3 = new Vertex();
            Vertex v4 = new Vertex();

            g.AddVertex(v1);
            g.AddVertex(v2);
            g.AddVertex(v3);
            g.AddVertex(v4);

            g.AddEdge(new Edge(v2, v1, 25f));
            g.AddEdge(new Edge(v1, v3, 10f));

            g.RemoveEdge(g.GetEdges()[1]);

            g.AddEdge(new Edge(v4, v2, 7f));

            g.RemoveVertex(v1);
            g.RemoveVertex(v2);

            g.AddEdge(new Edge(v3, v4, 30f));
            g.AddEdge(new Edge(v4, v3, 27f));

            Console.WriteLine("Testing graph insertion and deletion");

            g.PrintMatrix();

            Console.WriteLine();
            Graph g2 = new Graph();
            g.CopyTo(g2);
            g2.PrintMatrix();
        }