Spaces:
Sleeping
Sleeping
Commit
·
0e3c4d0
1
Parent(s):
33d7cfe
initial commit
Browse files- psychohistory.py +3 -2
psychohistory.py
CHANGED
@@ -33,6 +33,7 @@ def generate_tree(current_x, current_y, depth, max_depth, max_nodes, x_range, G,
|
|
33 |
|
34 |
|
35 |
|
|
|
36 |
def build_graph_from_json(json_data, G):
|
37 |
"""Builds a graph from JSON data, handling subevents recursively."""
|
38 |
|
@@ -44,14 +45,14 @@ def build_graph_from_json(json_data, G):
|
|
44 |
label = event_data['name']
|
45 |
G.add_node(node_id, pos=pos, label=label)
|
46 |
if parent_id is not None:
|
47 |
-
G.add_edge(parent_id, node_id)
|
48 |
|
49 |
subevents = event_data.get('subevents', {}).get('event', [])
|
50 |
if not isinstance(subevents, list):
|
51 |
subevents = [subevents]
|
52 |
|
53 |
for subevent in subevents:
|
54 |
-
add_event(node_id, subevent, depth + 1)
|
55 |
|
56 |
# Iterate through all top-level events
|
57 |
for event_data in json_data.get('events', {}).values():
|
|
|
33 |
|
34 |
|
35 |
|
36 |
+
|
37 |
def build_graph_from_json(json_data, G):
|
38 |
"""Builds a graph from JSON data, handling subevents recursively."""
|
39 |
|
|
|
45 |
label = event_data['name']
|
46 |
G.add_node(node_id, pos=pos, label=label)
|
47 |
if parent_id is not None:
|
48 |
+
G.add_edge(parent_id, node_id) # Connect to parent
|
49 |
|
50 |
subevents = event_data.get('subevents', {}).get('event', [])
|
51 |
if not isinstance(subevents, list):
|
52 |
subevents = [subevents]
|
53 |
|
54 |
for subevent in subevents:
|
55 |
+
add_event(node_id, subevent, depth + 1) # Recursively add subevents
|
56 |
|
57 |
# Iterate through all top-level events
|
58 |
for event_data in json_data.get('events', {}).values():
|