private void GenerateGraph(string planningMode, BatteryType batteryType) { Console.WriteLine("[DEBUG MESSAGE]: GenerateGraph() Start"); LocationCtr locationCtr = new LocationCtr(); // Get all locations, filter for type 3 (BatteryStation) // l => l.Type == 3 (Return l where l.type is equal to 3) List<Location> locations = locationCtr.GetAllLocations().FindAll(l => l.Type == 3); List<Connection> connections = locationCtr.GetAllConnections(); // Iterate over the location collection, add these to the graph. foreach (Location l in locations) { this.graph.AddLocation(l); } // Iterate over the connection collection, add these to the graph // including start vertex, end vertex and edge weight. foreach (Connection c in connections) { //TODO Uncomment //this.graph.AddConnection(c.From, c.To, c.Distance); } Console.WriteLine("[DEBUG MESSAGE]: GenerateGraph() End"); }
/// <summary> /// Generates the graph with all locations and connections. /// The connections are added to the adjacents list on the location. /// </summary> private void GenerateGraph() { LocationCtr locationCtr = new LocationCtr(); List<Location> locations = locationCtr.GetAllLocations(); List<Connection> connections = locationCtr.GetAllConnections(); foreach (Location l in locations) { l.GeoCoordinate.Longitude = l.Longitude; l.GeoCoordinate.Latitude = l.Latitude; this.graph.AddLocation(l); } foreach (Connection c in connections) { this.graph.AddConnection(c.From, c.To, c.Distance); } }