thearn commited on
Commit
135bcee
·
1 Parent(s): 7ddd13d

fixed label

Browse files
Files changed (1) hide show
  1. app.py +28 -33
app.py CHANGED
@@ -5,7 +5,6 @@ from streamlit_agraph import agraph, Config
5
 
6
  from src.network import make_payload, get_graph
7
  from src.graph import build_tree_structure, create_hierarchical_view, tree_to_dot
8
- from src.viz import create_pyvis_network
9
 
10
  def get_id_from_input(val: str) -> Optional[int]:
11
  try:
@@ -23,14 +22,17 @@ def display_tree_summary(graph: Dict[str, Any], root_id: int) -> None:
23
  for node in tree.values():
24
  depth = node["depth"]
25
  depth_counts[depth] = depth_counts.get(depth, 0) + 1
26
- col1, col2, col3 = st.columns(3)
 
 
27
  with col1:
28
  st.metric("Total Mathematicians", total_nodes)
29
- with col2:
30
  st.metric("Generations Back", max_depth)
31
- with col3:
32
  root_name = tree.get(root_id, {}).get("name", "Unknown")
33
- st.metric("Root", root_name)
 
 
34
  def main():
35
  st.title("Math Genealogy Ancestor Tree")
36
  st.write("Interactive visualization of academic advisor relationships from the Mathematics Genealogy Project")
@@ -157,12 +159,32 @@ def main():
157
 
158
  st.divider()
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  # visualization options
161
  st.subheader("Choose Visualization")
162
 
163
  viz_option = st.radio(
164
  "Select visualization type:",
165
- ["Interactive Hierarchical Tree", "Interactive Network", "Traditional Graph (Graphviz)"],
166
  help="Different views for exploring the genealogy tree"
167
  )
168
 
@@ -222,36 +244,9 @@ def main():
222
  else:
223
  st.warning("No data to display with current filters.")
224
 
225
- elif viz_option == "Interactive Network":
226
- st.write("**Interactive Network View** - Explore with zoom, pan, and physics simulation")
227
-
228
- with st.spinner("Generating interactive network..."):
229
- html_content = create_pyvis_network(graph, root_id)
230
- st.components.v1.html(html_content, height=650)
231
-
232
  else: # Traditional Graph
233
  st.write("**Traditional Graph View** - Standard graphviz layout")
234
- dot = tree_to_dot(graph)
235
  st.graphviz_chart(dot)
236
-
237
- # export to pdf button
238
- import io
239
- from graphviz import Source
240
-
241
- pdf_bytes = None
242
- try:
243
- src = Source(dot)
244
- pdf_bytes = src.pipe(format="pdf")
245
- except Exception as e:
246
- st.warning(f"Could not generate PDF: {e}")
247
-
248
- if pdf_bytes:
249
- st.download_button(
250
- label="Download Graph as PDF",
251
- data=pdf_bytes,
252
- file_name="math_genealogy_tree.pdf",
253
- mime="application/pdf"
254
- )
255
 
256
  # search functionality
257
  st.divider()
 
5
 
6
  from src.network import make_payload, get_graph
7
  from src.graph import build_tree_structure, create_hierarchical_view, tree_to_dot
 
8
 
9
  def get_id_from_input(val: str) -> Optional[int]:
10
  try:
 
22
  for node in tree.values():
23
  depth = node["depth"]
24
  depth_counts[depth] = depth_counts.get(depth, 0) + 1
25
+
26
+ # display metrics in two columns to give more space
27
+ col1, col2 = st.columns(2)
28
  with col1:
29
  st.metric("Total Mathematicians", total_nodes)
 
30
  st.metric("Generations Back", max_depth)
31
+ with col2:
32
  root_name = tree.get(root_id, {}).get("name", "Unknown")
33
+ st.write("**Root Mathematician:**")
34
+ st.write(root_name)
35
+
36
  def main():
37
  st.title("Math Genealogy Ancestor Tree")
38
  st.write("Interactive visualization of academic advisor relationships from the Mathematics Genealogy Project")
 
159
 
160
  st.divider()
161
 
162
+ # export to pdf button
163
+ import io
164
+ from graphviz import Source
165
+
166
+ dot = tree_to_dot(graph)
167
+ pdf_bytes = None
168
+ try:
169
+ src = Source(dot)
170
+ pdf_bytes = src.pipe(format="pdf")
171
+ except Exception as e:
172
+ st.warning(f"Could not generate PDF: {e}")
173
+
174
+ if pdf_bytes:
175
+ st.download_button(
176
+ label="Download Graph as PDF",
177
+ data=pdf_bytes,
178
+ file_name="math_genealogy_tree.pdf",
179
+ mime="application/pdf"
180
+ )
181
+
182
  # visualization options
183
  st.subheader("Choose Visualization")
184
 
185
  viz_option = st.radio(
186
  "Select visualization type:",
187
+ ["Interactive Hierarchical Tree", "Traditional Graph (Graphviz)"],
188
  help="Different views for exploring the genealogy tree"
189
  )
190
 
 
244
  else:
245
  st.warning("No data to display with current filters.")
246
 
 
 
 
 
 
 
 
247
  else: # Traditional Graph
248
  st.write("**Traditional Graph View** - Standard graphviz layout")
 
249
  st.graphviz_chart(dot)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
 
251
  # search functionality
252
  st.divider()