Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -65,19 +65,26 @@ def display_spectral_embedding():
|
|
65 |
grid_size = st.slider("Choose grid size (n x n):", min_value=3, max_value=10, value=6)
|
66 |
G_custom = nx.grid_2d_graph(grid_size, grid_size)
|
67 |
|
68 |
-
#
|
69 |
-
|
70 |
|
71 |
-
# Remove selected edges
|
72 |
-
G_custom.remove_edges_from(removed_edges)
|
73 |
-
|
74 |
-
options = {"node_color": "C0", "node_size": 100}
|
75 |
fig, axs = plt.subplots(3, 3, figsize=(12, 12))
|
76 |
axs = axs.flatten()
|
77 |
|
78 |
-
#
|
79 |
for i in range(7):
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
st.pyplot(fig)
|
83 |
|
|
|
65 |
grid_size = st.slider("Choose grid size (n x n):", min_value=3, max_value=10, value=6)
|
66 |
G_custom = nx.grid_2d_graph(grid_size, grid_size)
|
67 |
|
68 |
+
# List all edges to allow removal
|
69 |
+
all_edges = list(G_custom.edges)
|
70 |
|
|
|
|
|
|
|
|
|
71 |
fig, axs = plt.subplots(3, 3, figsize=(12, 12))
|
72 |
axs = axs.flatten()
|
73 |
|
74 |
+
# Loop through each subplot and allow edge removal individually
|
75 |
for i in range(7):
|
76 |
+
selected_edges = st.multiselect(f"Select edges to remove for graph {i+1}:",
|
77 |
+
options=[str(edge) for edge in all_edges])
|
78 |
+
|
79 |
+
# Convert the selected edges from string to tuple
|
80 |
+
edges_to_remove = [tuple(eval(edge)) for edge in selected_edges]
|
81 |
+
|
82 |
+
# Remove the selected edges
|
83 |
+
G_custom_copy = G_custom.copy()
|
84 |
+
G_custom_copy.remove_edges_from(edges_to_remove)
|
85 |
+
|
86 |
+
# Draw the graph with removed edges
|
87 |
+
nx.draw_spectral(G_custom_copy, **{"node_color": "C0", "node_size": 100}, ax=axs[i])
|
88 |
|
89 |
st.pyplot(fig)
|
90 |
|