shukdevdatta123 commited on
Commit
bfa97dc
·
verified ·
1 Parent(s): a2d1ed5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -128,30 +128,29 @@ def display_custom_node_position():
128
  # Function to display Cluster Layout for Drawing: Cluster Layout
129
  def display_cluster_layout():
130
  st.title("Drawing: Cluster Layout")
131
-
132
- option = st.radio("Choose a graph type:", ("Default Example", "Create your own"))
133
 
134
- if option == "Default Example":
135
- G = nx.davis_southern_women_graph() # Example graph
136
- communities = nx.community.greedy_modularity_communities(G)
137
 
138
- # Compute positions for the node clusters as if they were themselves nodes in a supergraph using a larger scale factor
139
- supergraph = nx.cycle_graph(len(communities))
140
- superpos = nx.spring_layout(G, scale=50, seed=429)
141
 
142
- # Use the "supernode" positions as the center of each node cluster
143
- centers = list(superpos.values())
144
- pos = {}
145
- for center, comm in zip(centers, communities):
146
- pos.update(nx.spring_layout(nx.subgraph(G, comm), center=center, seed=1430))
147
 
148
  # Nodes colored by cluster
149
- for nodes, clr in zip(communities, ("tab:blue", "tab:orange", "tab:green")):
150
- nx.draw_networkx_nodes(G, pos=pos, nodelist=nodes, node_color=clr, node_size=100)
151
- nx.draw_networkx_edges(G, pos=pos)
152
 
153
- plt.tight_layout()
154
- st.pyplot(plt)
 
 
155
 
156
  # Display Basic: Properties if selected
157
  if sidebar_option == "Basic: Properties":
 
128
  # Function to display Cluster Layout for Drawing: Cluster Layout
129
  def display_cluster_layout():
130
  st.title("Drawing: Cluster Layout")
 
 
131
 
132
+ G = nx.davis_southern_women_graph() # Example graph
133
+ communities = nx.community.greedy_modularity_communities(G)
 
134
 
135
+ # Compute positions for the node clusters as if they were themselves nodes in a supergraph using a larger scale factor
136
+ supergraph = nx.cycle_graph(len(communities))
137
+ superpos = nx.spring_layout(G, scale=50, seed=429)
138
 
139
+ # Use the "supernode" positions as the center of each node cluster
140
+ centers = list(superpos.values())
141
+ pos = {}
142
+ for center, comm in zip(centers, communities):
143
+ pos.update(nx.spring_layout(nx.subgraph(G, comm), center=center, seed=1430))
144
 
145
  # Nodes colored by cluster
146
+ for nodes, clr in zip(communities, ("tab:blue", "tab:orange", "tab:green")):
147
+ nx.draw_networkx_nodes(G, pos=pos, nodelist=nodes, node_color=clr, node_size=100)
148
+ nx.draw_networkx_edges(G, pos=pos)
149
 
150
+ plt.tight_layout()
151
+ st.pyplot(plt)
152
+
153
+
154
 
155
  # Display Basic: Properties if selected
156
  if sidebar_option == "Basic: Properties":