diff --git a/.gitignore b/.gitignore index df329f5..7c7e0d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__/ *.pyc .DS_Store -.idea \ No newline at end of file +.idea +.input_files/ \ No newline at end of file diff --git a/DistrictHeatingNetworkCreator.py b/DistrictHeatingNetworkCreator.py index 34a1e21..765dece 100644 --- a/DistrictHeatingNetworkCreator.py +++ b/DistrictHeatingNetworkCreator.py @@ -221,13 +221,14 @@ class DistrictHeatingNetworkCreator: """ Add centroids to the final MST graph and connect them to their associated node on the graph. """ - for centroid in self.centroids: + for i, centroid in enumerate(self.centroids): centroid_tuple = (centroid.x, centroid.y) - self.final_mst.add_node(centroid_tuple, type='centroid') + building_id = self.building_ids[i] + self.final_mst.add_node(centroid_tuple, type='building', id=building_id) nearest_point = None min_distance = float('inf') for node in self.final_mst.nodes(): - if self.final_mst.nodes[node].get('type') != 'centroid': + if self.final_mst.nodes[node].get('type') != 'building': node_point = Point(node) distance = centroid.distance(node_point) if distance < min_distance: diff --git a/main.py b/main.py index 86809b0..32984b2 100644 --- a/main.py +++ b/main.py @@ -16,4 +16,7 @@ elapsed_time = end_time - start_time print(f"The simulation took {elapsed_time:.4f} seconds to run.") +for node in network_graph.nodes(data=True): + print(f"Node: {node[0]}, Type: {node[1].get('type', 'unknown')}, ID: {node[1].get('id', 'N/A')}") + dhn_creator.plot_network_graph()