Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,7 +40,7 @@ def dag_topological_layout():
|
|
40 |
)
|
41 |
|
42 |
if graph_mode == "Default Example":
|
43 |
-
#
|
44 |
G = nx.DiGraph(
|
45 |
[
|
46 |
("f", "a"),
|
@@ -73,14 +73,22 @@ def dag_topological_layout():
|
|
73 |
elif graph_mode == "Create Your Own":
|
74 |
st.write("### Custom DAG Creation")
|
75 |
|
76 |
-
#
|
77 |
-
num_nodes = st.
|
78 |
-
|
|
|
|
|
79 |
|
|
|
|
|
|
|
|
|
|
|
80 |
for i in range(num_nodes):
|
81 |
for j in range(i + 1, num_nodes):
|
82 |
-
|
83 |
-
|
|
|
84 |
|
85 |
# Create the custom DAG
|
86 |
G_custom = nx.DiGraph()
|
|
|
40 |
)
|
41 |
|
42 |
if graph_mode == "Default Example":
|
43 |
+
# Default DAG example
|
44 |
G = nx.DiGraph(
|
45 |
[
|
46 |
("f", "a"),
|
|
|
73 |
elif graph_mode == "Create Your Own":
|
74 |
st.write("### Custom DAG Creation")
|
75 |
|
76 |
+
# Allow the user to input the number of nodes
|
77 |
+
num_nodes = st.number_input("Enter the number of nodes", min_value=2, value=5)
|
78 |
+
|
79 |
+
# Create node names based on the number of nodes
|
80 |
+
nodes = [str(i) for i in range(num_nodes)]
|
81 |
|
82 |
+
st.write(f"### Nodes: {nodes}")
|
83 |
+
st.write("#### Add Edges between Nodes")
|
84 |
+
|
85 |
+
# Allow the user to select pairs of nodes to add edges
|
86 |
+
edges = []
|
87 |
for i in range(num_nodes):
|
88 |
for j in range(i + 1, num_nodes):
|
89 |
+
edge = (nodes[i], nodes[j])
|
90 |
+
if st.checkbox(f"Add edge from {edge[0]} to {edge[1]}", value=False):
|
91 |
+
edges.append(edge)
|
92 |
|
93 |
# Create the custom DAG
|
94 |
G_custom = nx.DiGraph()
|