public IEnumerable <Route> Handle(Request request, IRouteProblem problem) { ISolver solver = null; if (request.Solver == "BFS") { solver = new BFS(); } if (request.Solver == "DFS") { solver = new DFS(); } if (request.Solver == "Dijkstra") { if (request.Problem == "Time") { solver = new DijkstraTime(); } if (request.Problem == "Cost") { solver = new DijkstraCost(); } } if (solver != null) { problem.Accept(solver); return(problem.Results); } Console.WriteLine("Pick Solver failed"); return(null); }
public override IEnumerable <Route> Handle(Request request, IGraphDatabase graph) { if (request.Solver == "Dijkstra") { if (request.Problem == "Cost") { IAlgorithm solver = new DijkstraCost(); return(solver.Solve(graph, graph.GetByName(request.From), graph.GetByName(request.To))); } if (request.Problem == "Time") { IAlgorithm solver = new DijkstraTime(); return(solver.Solve(graph, graph.GetByName(request.From), graph.GetByName(request.To))); } } return(null); }
public DijkstraHandler(DijkstraCost dijkstraCostAlgorithm, DijkstraTime dijkstraTimeAlgorithm) { DijkstraCostAlgorithm = dijkstraCostAlgorithm; DijkstraTimeAlgorithm = dijkstraTimeAlgorithm; }