shukdevdatta123 commited on
Commit
2e88b92
·
verified ·
1 Parent(s): f38a7f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -79,9 +79,13 @@ def algorithms_greedy_coloring():
79
  if st.button("Generate Graph"):
80
  if nodes_input and edges_input:
81
  try:
82
- # Parse the input for nodes and edges
83
- nodes = list(map(int, nodes_input.split(",")))
84
- edges = [tuple(map(int, edge.strip()[1:-1].split(","))) for edge in edges_input.split("),")]
 
 
 
 
85
 
86
  G = nx.Graph()
87
  G.add_nodes_from(nodes)
 
79
  if st.button("Generate Graph"):
80
  if nodes_input and edges_input:
81
  try:
82
+ # Clean and parse the input for nodes (strip spaces, remove empty strings)
83
+ nodes = [node.strip() for node in nodes_input.split(",") if node.strip()]
84
+ nodes = list(map(int, nodes))
85
+
86
+ # Clean and parse the input for edges (strip spaces and remove empty strings)
87
+ edges = [edge.strip() for edge in edges_input.split("),") if edge.strip()]
88
+ edges = [tuple(map(int, edge.strip("()").split(","))) for edge in edges]
89
 
90
  G = nx.Graph()
91
  G.add_nodes_from(nodes)