Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,51 +29,6 @@ def draw_graph(G, pos=None, title="Graph Visualization"):
|
|
29 |
nx.draw(G, pos=pos, with_labels=True, node_color='lightblue', node_size=500, font_size=10, font_weight='bold')
|
30 |
st.pyplot(plt)
|
31 |
|
32 |
-
# Default example code
|
33 |
-
def default_example_circular_tree():
|
34 |
-
G = nx.balanced_tree(3, 5)
|
35 |
-
pos = nx.nx_agraph.pygraphviz_layout(G, prog="twopi", args="")
|
36 |
-
plt.figure(figsize=(8, 8))
|
37 |
-
nx.draw(G, pos, node_size=20, alpha=0.5, node_color="blue", with_labels=False)
|
38 |
-
plt.axis("equal")
|
39 |
-
st.pyplot(plt)
|
40 |
-
|
41 |
-
# Create your own graph option
|
42 |
-
def create_own_graph_circular_tree():
|
43 |
-
# Input fields to customize the graph
|
44 |
-
branching_factor = st.number_input("Branching Factor", min_value=2, max_value=10, value=3)
|
45 |
-
depth = st.number_input("Depth", min_value=1, max_value=10, value=5)
|
46 |
-
|
47 |
-
# Add a button to generate the graph
|
48 |
-
generate_button = st.button("Generate Graph")
|
49 |
-
|
50 |
-
if generate_button:
|
51 |
-
# Generate graph and layout
|
52 |
-
G = nx.balanced_tree(branching_factor, depth)
|
53 |
-
pos = nx.nx_agraph.pygraphviz_layout(G, prog="twopi", args="")
|
54 |
-
|
55 |
-
# Draw the graph
|
56 |
-
plt.figure(figsize=(8, 8))
|
57 |
-
nx.draw(G, pos, node_size=20, alpha=0.5, node_color="blue", with_labels=False)
|
58 |
-
plt.axis("equal")
|
59 |
-
st.pyplot(plt)
|
60 |
-
|
61 |
-
if sidebar_option == "Graphviz Layout: Circular Tree":
|
62 |
-
st.title("Graphviz Layout: Circular Tree")
|
63 |
-
|
64 |
-
# Provide options for Default Example or Custom Graph
|
65 |
-
graph_mode = st.radio(
|
66 |
-
"Choose a Mode:",
|
67 |
-
("Default Example", "Create Your Own"),
|
68 |
-
help="Default example shows a balanced tree graph, or you can create your own custom graph."
|
69 |
-
)
|
70 |
-
|
71 |
-
# Display the chosen option
|
72 |
-
if graph_mode == "Default Example":
|
73 |
-
default_example_circular_tree()
|
74 |
-
elif graph_mode == "Create Your Own":
|
75 |
-
create_own_graph_circular_tree()
|
76 |
-
|
77 |
if sidebar_option == "3D Drawing: Animations of 3D Rotation":
|
78 |
st.title("3D Drawing: Animations of 3D Rotation")
|
79 |
|
|
|
29 |
nx.draw(G, pos=pos, with_labels=True, node_color='lightblue', node_size=500, font_size=10, font_weight='bold')
|
30 |
st.pyplot(plt)
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
if sidebar_option == "3D Drawing: Animations of 3D Rotation":
|
33 |
st.title("3D Drawing: Animations of 3D Rotation")
|
34 |
|