neuralworm commited on
Commit
bca33fd
1 Parent(s): 711c0ff

initial commit

Browse files
Files changed (1) hide show
  1. psychohistory.py +5 -14
psychohistory.py CHANGED
@@ -156,19 +156,10 @@ def draw_global_tree_3d(G, filename='global_tree.png'):
156
  plt.savefig(filename, bbox_inches='tight')
157
  plt.close()
158
 
 
159
  def main(json_data):
160
  G = nx.DiGraph()
161
- build_graph_from_json(json_data, G)
162
-
163
- if mode == 'random':
164
- generate_tree(0, 0, 0, 5, 3, 10, G)
165
- elif mode == 'json' and input_file:
166
- with open(input_file, 'r') as file:
167
- json_data = file.read()
168
- build_graph_from_json(json_data, G)
169
- else:
170
- print("Invalid mode or input file not provided.")
171
- return
172
 
173
  draw_global_tree_3d(G, filename='global_tree.png')
174
 
@@ -187,8 +178,6 @@ def main(json_data):
187
  print(f"\nPath with the shortest duration: {' -> '.join(map(str, shortest_path))}")
188
  print(f"Duration: {max(G.nodes[node]['pos'][0] for node in shortest_path) - min(G.nodes[node]['pos'][0] for node in shortest_path):.2f}")
189
 
190
- draw_global_tree_3d(G, filename='global_tree.png')
191
-
192
  if best_path:
193
  draw_path_3d(G, best_path, 'best_path.png', 'blue')
194
  if worst_path:
@@ -198,7 +187,9 @@ def main(json_data):
198
  if shortest_path:
199
  draw_path_3d(G, shortest_path, 'shortest_duration_path.png', 'purple')
200
 
201
- return 'global_tree.png'
 
 
202
 
203
 
204
  if __name__ == "__main__":
 
156
  plt.savefig(filename, bbox_inches='tight')
157
  plt.close()
158
 
159
+
160
  def main(json_data):
161
  G = nx.DiGraph()
162
+ build_graph_from_json(json_data, G) # Build graph from the provided JSON data
 
 
 
 
 
 
 
 
 
 
163
 
164
  draw_global_tree_3d(G, filename='global_tree.png')
165
 
 
178
  print(f"\nPath with the shortest duration: {' -> '.join(map(str, shortest_path))}")
179
  print(f"Duration: {max(G.nodes[node]['pos'][0] for node in shortest_path) - min(G.nodes[node]['pos'][0] for node in shortest_path):.2f}")
180
 
 
 
181
  if best_path:
182
  draw_path_3d(G, best_path, 'best_path.png', 'blue')
183
  if worst_path:
 
187
  if shortest_path:
188
  draw_path_3d(G, shortest_path, 'shortest_duration_path.png', 'purple')
189
 
190
+ return 'global_tree.png' # Return the filename of the global tree
191
+
192
+
193
 
194
 
195
  if __name__ == "__main__":