Update utils_gdmk.py
Browse files- utils_gdmk.py +12 -10
utils_gdmk.py
CHANGED
@@ -104,7 +104,7 @@ def inicializar_grafo():
|
|
104 |
# print("✅ Graph Edges:", list(G.edges))
|
105 |
|
106 |
def visualizar_grafo():
|
107 |
-
plt.figure(figsize=(
|
108 |
|
109 |
if len(G.nodes) == 0:
|
110 |
print("⚠️ Warning: The graph is empty! Check if data was loaded correctly.")
|
@@ -114,26 +114,28 @@ def visualizar_grafo():
|
|
114 |
return "graph.png"
|
115 |
|
116 |
centrality = nx.betweenness_centrality(G)
|
117 |
-
pos = nx.kamada_kawai_layout(G)
|
118 |
node_colors = []
|
119 |
node_sizes = []
|
120 |
-
|
121 |
for node in G.nodes():
|
122 |
-
if node in students:
|
123 |
-
node_colors.append('lightblue') # 🔵 Color para
|
124 |
else:
|
125 |
node_colors.append('lightgreen') # 🟢 Color para conceptos
|
126 |
-
|
127 |
-
|
128 |
nx.draw(
|
129 |
G, pos, with_labels=True, node_color=node_colors, edge_color='gray',
|
130 |
-
node_size=node_sizes, font_size=
|
131 |
)
|
|
|
132 |
edge_labels = nx.get_edge_attributes(G, 'label')
|
133 |
-
nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels, font_size=
|
134 |
-
plt.title("Red de Aportes - Optimizada
|
135 |
plt.savefig("graph.png")
|
136 |
plt.close()
|
|
|
137 |
return "graph.png"
|
138 |
|
139 |
def guardar_en_airtable(nombre, conceptos):
|
|
|
104 |
# print("✅ Graph Edges:", list(G.edges))
|
105 |
|
106 |
def visualizar_grafo():
|
107 |
+
plt.figure(figsize=(12, 8)) # Aumenta el tamaño de la imagen para mejorar la visibilidad
|
108 |
|
109 |
if len(G.nodes) == 0:
|
110 |
print("⚠️ Warning: The graph is empty! Check if data was loaded correctly.")
|
|
|
114 |
return "graph.png"
|
115 |
|
116 |
centrality = nx.betweenness_centrality(G)
|
117 |
+
pos = nx.kamada_kawai_layout(G, scale=2.0) # 🔄 Expandir el grafo
|
118 |
node_colors = []
|
119 |
node_sizes = []
|
120 |
+
|
121 |
for node in G.nodes():
|
122 |
+
if node in students:
|
123 |
+
node_colors.append('lightblue') # 🔵 Color para estudiantes
|
124 |
else:
|
125 |
node_colors.append('lightgreen') # 🟢 Color para conceptos
|
126 |
+
node_sizes.append(800 + 5000 * centrality.get(node, 0)) # 🔽 Reduce la escala
|
127 |
+
|
128 |
nx.draw(
|
129 |
G, pos, with_labels=True, node_color=node_colors, edge_color='gray',
|
130 |
+
node_size=node_sizes, font_size=8 # 🔄 Reduce font_size para más espacio
|
131 |
)
|
132 |
+
|
133 |
edge_labels = nx.get_edge_attributes(G, 'label')
|
134 |
+
nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels, font_size=7)
|
135 |
+
plt.title("Red de Aportes - Optimizada y Expandida")
|
136 |
plt.savefig("graph.png")
|
137 |
plt.close()
|
138 |
+
|
139 |
return "graph.png"
|
140 |
|
141 |
def guardar_en_airtable(nombre, conceptos):
|