private void btnCalc_Click(object sender, EventArgs e) { if (cmbLocations.SelectedIndex != -1) { RouteEngine.RouteEngine _routeEngine = new RouteEngine.RouteEngine(); foreach (Connection connection in _connections) { _routeEngine.Connections.Add(connection); } foreach (Location _location in _guiLocations) { _routeEngine.Locations.Add(_location); } Dictionary <Location, Route> _shortestPaths = _routeEngine.CalculateMinCost((Location)cmbLocations.SelectedItem); listBox1.Items.Clear(); List <Location> _shortestLocations = (List <Location>)(from s in _shortestPaths orderby s.Value.Cost select s.Key).ToList(); foreach (Location _location in _shortestLocations) { listBox1.Items.Add(_shortestPaths[_location]); } } else { MessageBox.Show("Please select a position"); } }
private void btnCalc_Click(object sender, EventArgs e) { if (cmbLocations.SelectedIndex != -1) { RouteEngine.RouteEngine _routeEngine = new RouteEngine.RouteEngine(); foreach (Connection connection in _connections) { _routeEngine.Connections.Add(connection); } foreach (Location _location in _guiLocations) { _routeEngine.Locations.Add(_location); } Dictionary<Location, Route> _shortestPaths = _routeEngine.CalculateMinCost((Location)cmbLocations.SelectedItem); listBox1.Items.Clear(); List<Location> _shortestLocations = (List<Location>)(from s in _shortestPaths orderby s.Value.Cost select s.Key).ToList(); foreach (Location _location in _shortestLocations) { listBox1.Items.Add(_shortestPaths[_location]); } } else { MessageBox.Show("Please select a position"); } }
static void Main(string[] args) { var routeEngine = new RouteEngine(); var res = routeEngine.ComputeRoute(null, 1, 2); var path = res.GetPath(); System.Console.WriteLine(res.ToString()); System.Console.Read(); }
static void Main(string[] args) { /*var t1 = new TransportCenter(); * t1.Name = "DARFUR"; * t1.Id = 19; * * var t2 = new TransportCenter(); * t2.Name = "ADDIS_ABEBA"; * t2.Id = 17;*/ var dao = new TransportCenterDAO(); var t1 = dao.FetchOne(2); var t2 = dao.FetchOne(23); var watch = System.Diagnostics.Stopwatch.StartNew(); var routeEngine = new RouteEngine(); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; var res = routeEngine.ComputeRoute(null, t1, t2); System.Console.WriteLine(elapsedMs); //System.Console.WriteLine(res.ToString()); System.Console.Read(); /*RoutesDAO routesDAO = new RoutesDAO(); * List<Routes> routes = routesDAO.FetchAll(); * foreach (var route in routes) * { * System.Console.WriteLine(route.Id); * System.Console.WriteLine(route.CenterA.Name); * System.Console.WriteLine(route.CenterB.Name); * System.Console.WriteLine(route.TravelTime); * System.Console.WriteLine("-----------------"); * } * System.Console.Read();*/ }
public Table() { IsBallSelected = false; SelectedPoint = new Point(-1, -1); gametable = new short[tableWidth, tableHeight]; for (int i = 0; i < 3; ) { Random rand = new Random(); int x = rand.Next(tableWidth); int y = rand.Next(tableHeight); int value = rand.Next(7); ++value; if (gametable[x, y] == 0) { gametable[x, y] = (short)value; ++i; } } locations = new Location[tableWidth, tableHeight]; engine = new RouteEngine.RouteEngine(); for (int i = 0; i < tableWidth; i++) { for (int j = 0; j < tableHeight; j++) { locations[i, j] = new Location() { Identifier = i + "," + j }; engine.Locations.Add(locations[i, j]); } } }