예제 #1
0
        static void Main(string[] args)
        {
            var graph = new Graph <int, string>();

            graph.AddNode(1);
            graph.AddNode(2);

            graph.Connect(0, 1, 5, "some custom information in edge"); //First node has key equal 0

            var dijkstra = new Dijkstra <int, string>(graph);
            IShortestPathResult result = dijkstra.Process(0, 1); //result contains the shortest path

            var path = result.GetPath();

            graph.Reset();

            var bfs = new BfsParallel <int, string>(graph);

            IShortestPathResult bfsResult = bfs.Process(0, 1);

            var bfsPath = bfsResult.GetPath();

            if (!bfsPath.SequenceEqual(path))
            {
                throw new Exception("The path should be the same.");
            }
        }
예제 #2
0
        public override IShortestPathResult GetPath()
        {
            var bfs = new BfsParallel <int, string>(Graph);

            return(bfs.Process(From, To));
        }