コード例 #1
0
        static void Main(string[] args)
        {
            Graph <string> testGraph = new Graph <string>();

            var a = testGraph.AddVertex("Toledo");
            var b = testGraph.AddVertex("FlagStaff");
            var c = testGraph.AddVertex("Seattle");

            testGraph.AddDirectedEdge(a, b, 22);
            testGraph.AddDirectedEdge(b, c, 25);
            testGraph.AddDirectedEdge(c, a, 15555);

            testGraph.Print();
        }
コード例 #2
0
        static void GraphMethod()
        {
            Graph <string> graph = new Graph <string>();

            var nd = graph.AddNode("North Dakota");
            var mt = graph.AddNode("Montana");
            var ga = graph.AddNode("Georgia");
            var ca = graph.AddNode("California");
            var wa = graph.AddNode("Washington");

            graph.AddDirectedEdge(wa, nd, 125);
            graph.AddUndirectedEdge(ca, mt, 100);
            graph.AddDirectedEdge(ga, mt, 72);
            graph.AddUndirectedEdge(wa, ca, 11);
            graph.AddDirectedEdge(nd, mt, 7);

            graph.Print();

            var neighbors = graph.GetNeighbors(wa);

            var getAll = graph.GetAllVertices();
        }