Skip to content

Commit 7511236

Browse files
authored
Fix draw_nx_graph
1 parent ebc562c commit 7511236

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

causallearn/graph/GraphClass.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self, no_of_var):
3535
self.redundant_nodes = [] # store the list of redundant nodes (for subgraphs)
3636
self.nx_graph = nx.DiGraph() # store the directed graph
3737
self.nx_skel = nx.Graph() # store the undirected graph
38+
self.labels = {}
3839
self.prt_m = {} # store the parents of missingness indicators
3940
self.mvpc = None
4041

@@ -151,6 +152,7 @@ def rearrange(self, PATH):
151152
def to_nx_graph(self):
152153
"""Convert adjmat into a networkx.Digraph object named nx_graph"""
153154
nodes = range(len(self.G.graph))
155+
self.labels = {i:self.G.nodes[i].get_name() for i in nodes}
154156
self.nx_graph.add_nodes_from(nodes)
155157
undirected = self.find_undirected()
156158
directed = self.find_fully_directed()
@@ -179,6 +181,6 @@ def draw_nx_graph(self, skel=False):
179181
edges = g_to_be_drawn.edges()
180182
colors = [g_to_be_drawn[u][v]['color'] for u, v in edges]
181183
pos = nx.circular_layout(g_to_be_drawn)
182-
nx.draw(g_to_be_drawn, pos=pos, with_labels=True, edge_color=colors)
184+
nx.draw(g_to_be_drawn, pos=pos, with_labels=True, labels=self.labels, edge_color=colors)
183185
plt.draw()
184186
plt.show()

0 commit comments

Comments
 (0)