예제 #1
0
        public void TraverseByWeight_RespectMaxWeight()
        {
            Graph graph = new Graph();

            graph.AddNode("A");
            graph.AddNode("B");
            graph.AddNode("C");

            GraphEdge ab_edge = new GraphEdge("A", "B", 1);
            GraphEdge ba_edge = new GraphEdge("B", "A", 1);
            GraphEdge bc_edge = new GraphEdge("B", "C", 3);

            graph.AddEdge(ab_edge);
            graph.AddEdge(ba_edge);
            graph.AddEdge(bc_edge);

            GraphTraverser traverser = new GraphTraverser(graph);
            var            result    = traverser.TraverseByWeight("A", "C", 9);

            Assert.AreEqual(3, result.Count());
        }
예제 #2
0
        public IEnumerable <GraphRoute> GetRoutesByDistance(string from, string to, float maxTotalDistance)
        {
            GraphTraverser traverser = new GraphTraverser(m_map);

            return(traverser.TraverseByWeight(from, to, maxTotalDistance));
        }