prakharg24 commited on
Commit
5be171f
·
verified ·
1 Parent(s): 4f4f1a5

Update my_pages/multiverse.py

Browse files
Files changed (1) hide show
  1. my_pages/multiverse.py +15 -4
my_pages/multiverse.py CHANGED
@@ -23,11 +23,22 @@ choices_list = [
23
  ]}
24
  ]
25
 
26
- def build_tree_and_trace_path(selected_path):
27
  """
28
  Build tree nodes and edges. Then trace selected_path (one choice per stage)
29
  by walking children of the current node to find the matching label at each stage.
30
- Returns: node_labels, node_positions, edges, highlight_edges, highlight_nodes
 
 
 
 
 
 
 
 
 
 
 
31
  """
32
  node_labels = ["Start"]
33
  node_positions = [(0.0, 0.0)]
@@ -36,14 +47,13 @@ def build_tree_and_trace_path(selected_path):
36
 
37
  prev_nodes = [0] # nodes at previous stage (start)
38
  y_spacing_base = 1.0
39
- spread_factor = 1.5 # tune this to taste
40
 
41
  # Build nodes and edges stage by stage
42
  for stage_idx, stage in enumerate(choices_list, start=1):
43
  options = stage["options"]
44
  next_nodes = []
45
 
46
- # scaling: large spacing early, smaller spacing deeper
47
  scale = spread_factor ** (1.0 / stage_idx)
48
 
49
  for parent_order, parent_idx in enumerate(prev_nodes):
@@ -89,6 +99,7 @@ def build_tree_and_trace_path(selected_path):
89
  return node_labels, node_positions, edges, highlight_edges, highlight_nodes
90
 
91
 
 
92
  def render():
93
  st.markdown(
94
  """
 
23
  ]}
24
  ]
25
 
26
+ def build_tree_and_trace_path(selected_path, spread_factor=5.0):
27
  """
28
  Build tree nodes and edges. Then trace selected_path (one choice per stage)
29
  by walking children of the current node to find the matching label at each stage.
30
+
31
+ Parameters
32
+ ----------
33
+ selected_path : list of str
34
+ The path to highlight.
35
+ spread_factor : float (default=5.0)
36
+ Controls vertical spread. Larger values => more separation early,
37
+ less separation as depth increases.
38
+
39
+ Returns
40
+ -------
41
+ node_labels, node_positions, edges, highlight_edges, highlight_nodes
42
  """
43
  node_labels = ["Start"]
44
  node_positions = [(0.0, 0.0)]
 
47
 
48
  prev_nodes = [0] # nodes at previous stage (start)
49
  y_spacing_base = 1.0
 
50
 
51
  # Build nodes and edges stage by stage
52
  for stage_idx, stage in enumerate(choices_list, start=1):
53
  options = stage["options"]
54
  next_nodes = []
55
 
56
+ # scaling: huge spread at stage 1, tapering off deeper
57
  scale = spread_factor ** (1.0 / stage_idx)
58
 
59
  for parent_order, parent_idx in enumerate(prev_nodes):
 
99
  return node_labels, node_positions, edges, highlight_edges, highlight_nodes
100
 
101
 
102
+
103
  def render():
104
  st.markdown(
105
  """