Update app.py
Browse files
app.py
CHANGED
@@ -91,6 +91,17 @@ def inicializar_grafo():
|
|
91 |
print("Graph Initialized with Nodes:", G.nodes()) # 馃攳 Debugging: Print nodes
|
92 |
print("Graph Initialized with Edges:", G.edges()) # 馃攳 Debugging: Print edges
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
def guardar_en_airtable(nombre, conceptos):
|
95 |
if isinstance(conceptos, str):
|
96 |
conceptos = [c.strip() for c in conceptos.split(',') if c.strip()] # Ensure it's a list
|
@@ -116,18 +127,7 @@ def agregar_aporte(nombre, texto):
|
|
116 |
guardar_en_airtable(nombre, conceptos)
|
117 |
return visualizar_grafo()
|
118 |
|
119 |
-
|
120 |
-
plt.figure(figsize=(10, 6))
|
121 |
-
pos = nx.spring_layout(G)
|
122 |
-
edge_labels = nx.get_edge_attributes(G, 'label')
|
123 |
-
nx.draw(G, pos, with_labels=True, node_color='lightblue', edge_color='gray', node_size=2000, font_size=10)
|
124 |
-
nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels, font_size=8)
|
125 |
-
plt.title("Red de Aportes")
|
126 |
-
plt.savefig("graph.png")
|
127 |
-
plt.close()
|
128 |
-
return "graph.png"
|
129 |
-
|
130 |
-
inicializar_grafo() # Call this before displaying the graph
|
131 |
|
132 |
iface = gr.Blocks()
|
133 |
|
|
|
91 |
print("Graph Initialized with Nodes:", G.nodes()) # 馃攳 Debugging: Print nodes
|
92 |
print("Graph Initialized with Edges:", G.edges()) # 馃攳 Debugging: Print edges
|
93 |
|
94 |
+
def visualizar_grafo():
|
95 |
+
plt.figure(figsize=(10, 6))
|
96 |
+
pos = nx.spring_layout(G)
|
97 |
+
edge_labels = nx.get_edge_attributes(G, 'label')
|
98 |
+
nx.draw(G, pos, with_labels=True, node_color='lightblue', edge_color='gray', node_size=2000, font_size=10)
|
99 |
+
nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels, font_size=8)
|
100 |
+
plt.title("Red de Aportes")
|
101 |
+
plt.savefig("graph.png")
|
102 |
+
plt.close()
|
103 |
+
return "graph.png"
|
104 |
+
|
105 |
def guardar_en_airtable(nombre, conceptos):
|
106 |
if isinstance(conceptos, str):
|
107 |
conceptos = [c.strip() for c in conceptos.split(',') if c.strip()] # Ensure it's a list
|
|
|
127 |
guardar_en_airtable(nombre, conceptos)
|
128 |
return visualizar_grafo()
|
129 |
|
130 |
+
# inicializar_grafo() # Call this before displaying the graph
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
iface = gr.Blocks()
|
133 |
|