diff --git a/__pycache__/commuter_model.cpython-312.pyc b/__pycache__/commuter_model.cpython-312.pyc deleted file mode 100644 index ef2f553..0000000 Binary files a/__pycache__/commuter_model.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/commuter_model.cpython-313.pyc b/__pycache__/commuter_model.cpython-313.pyc deleted file mode 100644 index 1784a45..0000000 Binary files a/__pycache__/commuter_model.cpython-313.pyc and /dev/null differ diff --git a/__pycache__/dqn_agent.cpython-312.pyc b/__pycache__/dqn_agent.cpython-312.pyc deleted file mode 100644 index de2bf5f..0000000 Binary files a/__pycache__/dqn_agent.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/dqn_agent.cpython-313.pyc b/__pycache__/dqn_agent.cpython-313.pyc deleted file mode 100644 index f991a4d..0000000 Binary files a/__pycache__/dqn_agent.cpython-313.pyc and /dev/null differ diff --git a/__pycache__/dqn_agent.cpython-314.pyc b/__pycache__/dqn_agent.cpython-314.pyc deleted file mode 100644 index 9e8d133..0000000 Binary files a/__pycache__/dqn_agent.cpython-314.pyc and /dev/null differ diff --git a/__pycache__/mbta_env.cpython-312.pyc b/__pycache__/mbta_env.cpython-312.pyc deleted file mode 100644 index cc07632..0000000 Binary files a/__pycache__/mbta_env.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/mbta_env.cpython-313.pyc b/__pycache__/mbta_env.cpython-313.pyc deleted file mode 100644 index 75c9f50..0000000 Binary files a/__pycache__/mbta_env.cpython-313.pyc and /dev/null differ diff --git a/__pycache__/mbta_env.cpython-314.pyc b/__pycache__/mbta_env.cpython-314.pyc deleted file mode 100644 index 7c49d6a..0000000 Binary files a/__pycache__/mbta_env.cpython-314.pyc and /dev/null differ diff --git a/env/network.py b/env/network.py index 6b2c7c6..19d6a80 100644 --- a/env/network.py +++ b/env/network.py @@ -157,11 +157,23 @@ def single_color(n): plt.show() if __name__ == "__main__": - G = build_graph() - - # save graph graph_path = _os.path.join(_PROJECT_ROOT, "outputs", "mbta_graph.pkl") - with open(graph_path, "wb") as f: - pickle.dump(G, f) + + if _os.path.exists(graph_path): + rebuild = input(f"Graph already exists at {graph_path}. Rebuild? (y/n): ").strip().lower() + if rebuild == "y": + G = build_graph() + with open(graph_path, "wb") as f: + pickle.dump(G, f) + print("Graph rebuilt and saved.") + else: + with open(graph_path, "rb") as f: + G = pickle.load(f) + print("Loaded existing graph.") + else: + G = build_graph() + with open(graph_path, "wb") as f: + pickle.dump(G, f) + print("Graph built and saved.") draw_graph(G) \ No newline at end of file