public static IEnumerable <IEnumerable <Tuple <Vector2, Vector2> > > DeterminationOfRoads(Vector2 startingBuilding, List <Vector2> destinationBuildings, List <Tuple <Vector2, Vector2> > roads) { FloydWarshallGraph fw_graph = new FloydWarshallGraph(); // Graph is empty fw_graph = InsertGraph(fw_graph, roads, startingBuilding, destinationBuildings); // Graph gets created here fw_graph.DisplayGraph(); // Graph gets displayed here on the console return(fw_graph.ShortestPaths(startingBuilding, destinationBuildings)); // Shortest path is determined between startingBuilding and destinationBuilding: is then stored in resultListBA variable }
static FloydWarshallGraph InsertGraph(FloydWarshallGraph graph, List <Tuple <Vector2, Vector2> > roadslist, Vector2 startPoint, List <Vector2> endPoints) { graph.AddNode(startPoint); // Adds startingBuilding as FIRST NODE to the Graph foreach (var road in roadslist) { graph.AddNode(road.Item1); // Item1 is STARTING POINT of ROAD graph.AddNode(road.Item2); // Item2 is END POINT of ROAD graph.AddRoad(road.Item1, road.Item2, (int)Vector2.Distance(road.Item1, road.Item2)); // Calculates the distance between the 2 points. Adds road to the Graph } foreach (var endpoint in endPoints) { graph.AddNode(endpoint); // Adds destinationBuildings as LAST NODE to the Graph } return(graph); }