Update app.py
Browse files
app.py
CHANGED
@@ -30,6 +30,16 @@ def draw_graph(G, pos=None, title="Graph Visualization"):
|
|
30 |
nx.draw(G, pos=pos, with_labels=True, node_color='lightblue', node_size=500, font_size=10, font_weight='bold')
|
31 |
st.pyplot(plt)
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
# Function to convert a sympy Boolean expression to a graph
|
34 |
def formula_to_circuit(formula):
|
35 |
circuit = nx.DiGraph()
|
|
|
30 |
nx.draw(G, pos=pos, with_labels=True, node_color='lightblue', node_size=500, font_size=10, font_weight='bold')
|
31 |
st.pyplot(plt)
|
32 |
|
33 |
+
def circuit_to_formula(circuit):
|
34 |
+
# Convert the circuit to an equivalent formula.
|
35 |
+
formula = nx.dag_to_branching(circuit)
|
36 |
+
# Transfer the operator or variable labels for each node from the
|
37 |
+
# circuit to the formula.
|
38 |
+
for v in formula:
|
39 |
+
source = formula.nodes[v]["source"]
|
40 |
+
formula.nodes[v]["label"] = circuit.nodes[source]["label"]
|
41 |
+
return formula
|
42 |
+
|
43 |
# Function to convert a sympy Boolean expression to a graph
|
44 |
def formula_to_circuit(formula):
|
45 |
circuit = nx.DiGraph()
|