shukdevdatta123 commited on
Commit
56973de
·
verified ·
1 Parent(s): deebd1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -45
app.py CHANGED
@@ -7,8 +7,7 @@ import numpy as np
7
  sidebar_option = st.sidebar.radio("Select an option",
8
  ["Select an option", "Basic: Properties",
9
  "Basic: Read and write graphs", "Basic: Simple graph",
10
- "Basic: Simple graph Directed", "Drawing: Custom Node Position",
11
- "Drawing: Chess Masters"])
12
 
13
  # Helper function to draw and display graph
14
  def draw_graph(G, pos=None, title="Graph Visualization"):
@@ -125,45 +124,6 @@ def display_custom_node_position():
125
  # Draw the graph
126
  draw_graph(G, pos)
127
 
128
- # Function to display Chess Masters Graphs for Drawing: Chess Masters
129
- def display_chess_masters():
130
- st.title("Drawing: Chess Masters")
131
-
132
- # Define the directed graph
133
- G = nx.DiGraph([(0, 3), (1, 3), (2, 4), (3, 5), (3, 6), (4, 6), (5, 6)])
134
-
135
- # Group nodes by column
136
- left_nodes = [0, 1, 2]
137
- middle_nodes = [3, 4]
138
- right_nodes = [5, 6]
139
-
140
- # Set the position according to column (x-coord)
141
- pos = {n: (0, i) for i, n in enumerate(left_nodes)}
142
- pos.update({n: (1, i + 0.5) for i, n in enumerate(middle_nodes)})
143
- pos.update({n: (2, i + 0.5) for i, n in enumerate(right_nodes)})
144
-
145
- # Define plot options
146
- options = {
147
- "node_size": 500,
148
- "node_color": "lightblue",
149
- "arrowsize": 20,
150
- "width": 2,
151
- "edge_color": "gray",
152
- }
153
-
154
- # Draw the graph with the specified positions and options
155
- nx.draw_networkx(G, pos, **options)
156
-
157
- # Set margins for the axes so that nodes aren't clipped
158
- ax = plt.gca()
159
- ax.margins(0.20)
160
-
161
- # Turn off the axis for better visualization
162
- plt.axis("off")
163
-
164
- # Show the plot
165
- st.pyplot(plt)
166
-
167
  # Display Basic: Properties if selected
168
  if sidebar_option == "Basic: Properties":
169
  st.title("Basic: Properties")
@@ -268,7 +228,3 @@ elif sidebar_option == "Basic: Simple graph Directed":
268
  # Display Drawing: Custom Node Position if selected
269
  elif sidebar_option == "Drawing: Custom Node Position":
270
  display_custom_node_position()
271
-
272
- # Display Drawing: Chess Masters if selected
273
- elif sidebar_option == "Drawing: Chess Masters":
274
- display_chess_masters()
 
7
  sidebar_option = st.sidebar.radio("Select an option",
8
  ["Select an option", "Basic: Properties",
9
  "Basic: Read and write graphs", "Basic: Simple graph",
10
+ "Basic: Simple graph Directed", "Drawing: Custom Node Position"])
 
11
 
12
  # Helper function to draw and display graph
13
  def draw_graph(G, pos=None, title="Graph Visualization"):
 
124
  # Draw the graph
125
  draw_graph(G, pos)
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  # Display Basic: Properties if selected
128
  if sidebar_option == "Basic: Properties":
129
  st.title("Basic: Properties")
 
228
  # Display Drawing: Custom Node Position if selected
229
  elif sidebar_option == "Drawing: Custom Node Position":
230
  display_custom_node_position()