def plot_connections_graph(self, ax=None, figsize=(20, 20)): graph = self.uniquified_connection_graph def fragment_label(i): fragment = self.fragments_dict[i] return "\n".join([ str(fragment.seq.left_end), r"$\bf{%s}$" % fragment.original_construct.id, str(fragment.seq.right_end), ]) labels = {i: fragment_label(i) for i in graph} if ax is None: fig, ax = plt.subplots(1, 1, figsize=figsize) if len(graph): nx.draw_kamada_kawai( graph, labels=labels, font_color="k", edge_color="grey", font_size=12, node_color="w", node_size=3000, ) return ax
def plot_graph(g, a, attr, draw): orig_cmap = plt.cm.PuBu fixed_cmap = shiftedColorMap(orig_cmap, start=min(attr), midpoint=0.5, stop=max(attr), name='fixed') ## adjust colour reconstructed_a_padded according to features a = np.reshape(a, (a.shape[0], a.shape[1])) a_channel = np.copy(a) a_channel = np.tile(a_channel[:, :, None], [1, 1, 3]) ## broadcast 1 channel to 3 for node in range(0, len(g)): color = fixed_cmap(attr[node])[:3] a_channel[node, :node + 1] = a_channel[node, :node + 1] * color a_channel[:node, node] = a_channel[:node, node] * color if draw == True: fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(5, 3)) #plt.axis('off') plt.sca(axes[0]) nx.draw_kamada_kawai(g, node_color=attr, font_color='white', cmap = fixed_cmap) axes[1].set_axis_off() axes[1].imshow(a_channel) fig.tight_layout() return fixed_cmap, a_channel
def plot_network(self): plt.figure('Network') # node_color = [float(self.model.net.degree(nd)) for nd in self.model.net] dt = 1 / len(self.model.population_composition) color_key = {} for k in self.model.population_composition: color_key[k] = dt dt += dt node_color = [ float(color_key[self.model.net.nodes[nd]['strat']]) for nd in self.model.net ] options = { 'node_color': node_color, 'node_size': 250, 'width': .5, 'with_labels': False } nx.draw_kamada_kawai(self.model.net, **options) # plt.legend(tuple(color_key.keys()),tuple(color_key.values())) pos = nx.kamada_kawai_layout(self.model.net) labels = nx.get_node_attributes(self.model.net, 'agent_id') nx.draw_networkx_labels(self.model.net, pos, labels, font_size=8, font_color='w', font_weight='bold')
def do_matching(graph, visualize=True): print("Starting model") weights = dict() graph = {int(key): graph[key] for key in graph} E = set() V = graph.keys() for v in V: original = v for u, weight in graph[original]: s, t = (u, v) if u < v else (v, u) edge = (s, t) E.add(edge) weights[original, u] = weight if visualize: graph = nx.Graph() graph.add_nodes_from(V) graph.add_edges_from(E) nx.draw_kamada_kawai(graph) plt.show() model = Model("Maximum matching") edge_vars = {e: model.add_var(var_type=BINARY) for e in E} for v in V: model += xsum(edge_vars[s, t] for s, t in E if v in [s, t]) <= 1 model.objective = maximize( xsum( xsum(((weights[edge] + weights[edge[1], edge[0]]) / 2) * edge_vars[edge] for edge in E) for edge in E)) model.optimize(max_seconds=300) return sorted([e for e in E if edge_vars[e].x > .01])
def plot_graph(G, benchmark): fig = plt.figure() if benchmark == 'dwt': nx.draw(G, with_labels=True, node_size=500, alpha=.5, font_weight='bold') elif benchmark == 'BlackScholes': nx.draw(G, with_labels=True, node_size=500, alpha=.5, font_weight='bold') elif benchmark == 'Jacobi': nx.draw(G, with_labels=True, node_size=500, alpha=.5, font_weight='bold') else: nx.draw_kamada_kawai(G, with_labels=True, node_size=500, alpha=.5, font_weight='bold') plt.show()
def DrawNetwork(self, image_file): # 画图,暂时不太成功。。 std_dic={} node_list,color_list,shell_list=[],[],[] openFile=open('xinjigengsi.txt',encoding='utf-8') lines=openFile.readlines() for line in lines: items=line.strip().split(' ') if items[1] not in std_dic: std_dic[items[1]]=[items[1]] if items[0] not in std_dic[items[1]]: std_dic[items[1]].append(items[0]) openFile.close() g=nx.Graph() for key,value in std_dic.items(): for name in value: if name not in node_list: node_list.append(name) color_list.append('red') g.add_node(name) shell_list.append(node_list) for name in node_list: for j in range(0,self.number): if self.weight_matrix[self.nodes_index[name],j]>20: g.add_edge(name,self.nodes[j]) shell_list.append(list(set(g.nodes()).difference(set(node_list)))) print(len(node_list),g.number_of_nodes(),g.number_of_edges()) color_list.extend(['yellow']*(g.number_of_nodes()-len(node_list))) nx.draw_kamada_kawai(g,with_labels=True,node_size=100,font_size=4,node_color=color_list) plt.savefig(image_file,dpi=1000)
def visualize_kamada_BMI_sized_colored(G): nx.draw_kamada_kawai(G, labels=get_labels(G), with_labels=True, node_size=get_size(G), node_color=get_colors(G)) plt.show()
def plot_connections_graph(self, ax=None, figsize=(20, 20)): """Plot the mix's graph of connections between fragments.""" graph = self.uniquified_connection_graph def fragment_label(i): fragment = self.fragments_dict[i] return "\n".join( [fragment.text_representation_in_plots().replace("_", "-")]) labels = {i: fragment_label(i) for i in graph} if ax is None: fig, ax = plt.subplots(1, 1, figsize=figsize) if len(graph): nx.draw_kamada_kawai( graph, labels=labels, font_color="k", edge_color="grey", font_size=12, node_color="w", node_size=3000, ) if self.name is not None: ax.set_title(self.name, loc="left") return ax
def draw_mrt(self, img, rel_mat): if rel_mat.shape[0] == 0: return img mrt = nx.DiGraph() node_num = np.max(np.where(rel_mat > 0)[0]) + 1 for obj1 in xrange(node_num): mrt.add_node("ind" + str(obj1)) for obj2 in xrange(obj1): if rel_mat[obj1, obj2].item() == cfg.VMRN.FATHER: # OBJ1 is the father of OBJ2 mrt.add_edge("ind" + str(obj2), "ind" + str(obj1)) if rel_mat[obj1, obj2].item() == cfg.VMRN.CHILD: # OBJ1 is the father of OBJ2 mrt.add_edge("ind" + str(obj1), "ind" + str(obj2)) fig = plt.figure(0, figsize=(3, 3)) nx.draw_kamada_kawai(mrt, with_labels=True, arrowstyle='fancy', font_size=16, node_color='#FFF68F', node_shape='s', node_size=2000) # grab the pixel buffer and dump it into a numpy array rel_img = fig2data(fig) rel_img = cv2.resize(rel_img[:,:,:3], (250, 250), interpolation=cv2.INTER_LINEAR) # img = cv2.resize(img, (1000, 1000), interpolation=cv2.INTER_LINEAR) img[:250, :250] = rel_img plt.close(0) return img
def percolate(self, anim=False, fps=4, dpi=None): if anim: # make a custom 2-colour colormap cmap = colors.ListedColormap([(225/255,225/255,225/255), (0/255,50/255,100/255)]) bounds=[-2,0,2] # norm = colors.BoundaryNorm(bounds, cmap.N) # initialize the image if not os.path.exists('randtest'): os.makedirs('randtest') i = 1 while not self.end: plt.ion() fig, ax = plt.subplots() ax.axis("off") #for ind in range(0,10): nx.draw_kamada_kawai(self.graph, node_color = [self.graph.node[node]['val'] for node in self.graph], cmap=cmap, ax = ax, node_size = 10, figsize = (30,30)) plt.savefig(r'C:\Users\rinni\Documents\Python\randtest\randtest_%s.png' % i, format = "PNG") self.update() i = i + 1 os.system("ffmpeg -r 1 -i C:\\Users\\rinni\\Documents\\Python\\randtest\\randtest_%1d.png -vcodec mpeg4 -y randtest\\randtest.mp4") else: while not self.end: self.frac.append(self.frac_perc) self.update() print(self.frac_perc)
def draw(self, save_dir=None) -> None: node_color = [] for node in self.G.nodes: degree = self.G.degree(node) if degree == 0: color = "#fcb045" elif degree == 1: color = "#fd7435" elif degree == 2: color = "#fd4c2a" elif degree == 3: color = "#fd1d1d" elif degree == 4: color = "#c22b65" else: color = "#833ab4" node_color.append(copy.deepcopy(color)) nx.draw_kamada_kawai( self.G, with_labels=True, node_color=node_color, node_size=200, alpha=0.9, edge_color="#575757", linewidths=None, font_weight="bold", font_size=8, ) if save_dir is not None: plt.savefig(save_dir) else: plt.show()
def createAndInitNetwork(): #draw and show graph mapper['color'] = np.array(map(ord, mapper['group'])) nx.draw_kamada_kawai(graph, with_labels=True, node_color=mapper['color'], cmap=plt.cm.Greens) plt.show() #plt.savefig('../networks/network'+ sys.argv[1] +'.png') #calculate shortest path between all nodes pred, dist = nx.floyd_warshall_predecessor_and_distance(graph) for p in pred: commandCreate = 'python node.py ' + str(p) + ' ' + mapper['group'][ p] + ' ' + sys.argv[1] + ' ' + sys.argv[2] + ' ' + str(pred[p]) commandList.append(commandCreate) #clear ports to create nodes clearPort = 'sudo fuser -k -n tcp ' for g in nx.nodes(graph): clearPort = clearPort + str(8090 + g) + ' ' print clearPort os.system(clearPort) t = threading.Thread(target=(createNodes), args=()) t.start() time.sleep(1)
def showTopology(topology): G = nx.Graph() listColor = [] for u in topology.nodes: G.add_node(u) if topology.nodes[u][2] == "Core": if u in topology.listDCCore: listColor.append("red") else: listColor.append("darkred") elif topology.nodes[u][2] == "Edge": if u in topology.listDCEdge: listColor.append("blue") else: listColor.append("cyan") else: listColor.append("green") for (u,v) in topology.links: G.add_edge(u, v) nx.draw_kamada_kawai(G, node_color=listColor) plt.show()
def compare_graphs(file_path): matrix1 = np.loadtxt(file_path+'graph_1.txt') matrix2 = np.loadtxt(file_path+'graph_2.txt') G1 = nx.from_numpy_array(matrix1) G2 = nx.from_numpy_array(matrix2) fig = plt.figure() plt.subplot(221) plt.title('Graph N1') draw_matrix(matrix1) plt.subplot(222) plt.title('Graph N2') draw_matrix(matrix2) plt.subplot(223) nx.draw_kamada_kawai(G1, with_labels=True) plt.subplot(224) nx.draw_kamada_kawai(G2, with_labels=True) answer = '' res = check_isomorphism(matrix1, matrix2) if res < 0: answer = 'Some graph is not a tree' if res == 0: answer = 'Trees are not isomorphic' if res > 0: answer = 'Trees are isomorphic' plt.gcf().suptitle(answer, fontsize=10, y=0.05) plt.show() fig.savefig(file_path+'answer.png')
def showKawaiiProdCat(DFs): # KAMADA KAWAII G = nx.MultiGraph() # Trzeba zdropowac kolumienki z polem 'item' bo to psuje graf DFsWithoutItems = [] for x in range(0, 7): df = DFs[x][DFs[x].Object != 'item'] DFsWithoutItems.append(df) for x in range(0, 7): rels = retMappedRelation(DFsWithoutItems[x]) G.add_edges_from(rels) pos = nx.kamada_kawai_layout(G) nx.draw_kamada_kawai(G, edge_color='r') rels = retMappedRelation(DFsWithoutItems[6]) nx.draw_networkx_edges(G, pos, edgelist=rels, width=1, alpha=1, edge_color="g") nx.draw_networkx_labels(G, pos, font_size=6) plt.show()
def visualize_network(G: nx.Graph, layout: Optional[Layout], name='', save=False, edge_width_func: Callable[[nx.Graph], Sequence[Number]] = all_same, block=True, node_size: Union[Number, Sequence[Number]] = 50, node_color: Optional[Sequence[str]] = None) -> None: comps = tuple(nx.connected_components(G)) if node_color is None: node_color = colors_from_communities(comps) edge_width = edge_width_func(G) plt.title(f'{name}\n{len(comps)} Components') # node_size = np.array(tuple(nx.betweenness_centrality(G).values())) # node_size = np.array(tuple(nx.eigenvector_centrality_numpy(G).values())) if layout is None: nx.draw_kamada_kawai(G, node_size=node_size, node_color=node_color, width=edge_width) else: nx.draw(G, pos=layout, node_size=node_size, node_color=node_color, width=edge_width, with_labels=False) if save: plt.savefig(f'vis-{name}.png', dpi=300, format='png') plt.figure() else: plt.show(block=block) if not block: plt.figure()
def plot(self): """ function to plot the Graph :return: None """ options = { 'with_labels': True, 'node_color': 'lightblue', # blue 'node_size': 1000, 'node_shape': 's', # 'd', '^', 'o', '^', 'font_size': 20, 'font_weight': 'bold' } type_of_draw = 'kamada_kawai' # DRAW IN DIFFERENT LAYOUT if type_of_draw == 'planar': nx.draw_planar(self.Graph, **options) elif type_of_draw == 'spectral': nx.draw_spectral(self.Graph, **options) elif type_of_draw == 'kamada_kawai': nx.draw_kamada_kawai(self.Graph, **options) elif type_of_draw == 'spring': nx.draw_spring(self.Graph, **options) print("Plotting 4 You...") plt.draw() plt.show() # plt.savefig("saved_Plot4You.png") plt.clf()
def draw_graph(G, plt, print_pos=False, print_neg=False): '''Draw the graph G on plot plt, using the kamada_kawai method. Node colors: green for True, red for False, grey for Failed request''' colors = [] for node in G: if node.status == Node.status[True]: if print_pos: print("TRUE: {} {}".format(node.decision_func, node)) colors.append('green') elif node.status == Node.status[False]: if print_neg: print("FALSE: {} {}".format(node.decision_func, node)) colors.append('red') else: # Download error colors.append('grey') fig, ax = plt.subplots(figsize=(15, 10)) nx.draw_kamada_kawai(G, ax=ax, node_color=colors, with_labels=False, node_size=50, width=0.5, alpha=1)
def drawgraph(): data = twolists() lista, listb, = data[0], data[1] edges = [] for i in range(len(data[0])): for j in listb[i]: _tuple = (lista[i], j) edges.append(_tuple) G = nx.Graph() G.add_nodes_from(data[0]) G.add_edges_from(edges, alpha="0.2") options = { 'node_color': 'black', 'edge_color': 'blue', 'node_size': 5, 'alpha': 0.2, 'width': 1, 'node_shape': 'X', } nx.draw_kamada_kawai(G, color="black", with_labels=False, font_weight='bold', **options) plt.savefig("path.png", dpi=500) plt.show()
def plotGraph(self, colorArrangement): """ Plots the graph with the nodes colored according to the given color arrangement :param colorArrangement: a list of integers representing the suggested color arrangement fpo the nodes, one color per node in the graph """ if len(colorArrangement) != self.__len__(): raise ValueError("size of color list should be equal to ", self.__len__()) # create a list of the unique colors in the arrangement: colorList = list(set(colorArrangement)) # create the actual colors for the integers in the color list: colors = plt.cm.rainbow(np.linspace(0, 1, len(colorList))) # iterate over the nodes, and give each one of them its corresponding color: colorMap = [] for i in range(self.__len__()): color = colors[colorList.index(colorArrangement[i])] colorMap.append(color) # plot the nodes with their labels and matching colors: nx.draw_kamada_kawai(self.graph, node_color=colorMap, with_labels=True) #nx.draw_circular(self.graph, node_color=color_map, with_labels=True) return plt
def get_most_common_motifs(self, motif_length=5): """Method that gets 8 or 9 most common motifs for a given project or group of projects.""" motifs = mf.get_motifs(self.project_ids, motif_length, self.num_motifs_to_sample, self.commits_dl) if motif_length == 5: fig, axs = plt.subplots(3, 3) else: fig, axs = plt.subplots(4, 2) fig.set_size_inches(18.5, 10.5) for n, key in enumerate(sorted(motifs, key=motifs.get, reverse=True)): if motif_length == 5: if n >= 9: break nx.draw_kamada_kawai(key, node_size=300, width=1.5, arrowsize=50, ax=axs.flatten()[n]) axs.flatten()[n].set_title( '{}. {}% (n={})'.format(str(n + 1), str(round(100*(motifs[key] / self.num_motifs_to_sample))), str(motifs[key])), fontsize=20) else: if n >= 8: break if n == 0: nx.draw_kamada_kawai(key, node_size=100, width=1, ax=axs.flatten()[n]) axs.flatten()[n].set_title('{}. {}% (n={})'.format(str(n + 1), str(round(100 * (motifs[key] / self.num_motifs_to_sample))), str(motifs[key])),fontsize = 20) else: nx.draw_spring(key, node_size=100, width=.8, arrowsize=20, ax=axs.flatten()[n]) axs.flatten()[n].set_title('{}. {}% (n={})'.format(str(n + 1), str(round(100 * (motifs[key] / self.num_motifs_to_sample))), str(motifs[key])),fontsize = 20) fig.suptitle('Most Common Motifs Length {} Occurrence Rate and Count'.format(motif_length), fontsize=25) fig.savefig('results/motif_{}_visual.png'.format(motif_length)) return fig
def draw_network(G: Graph, output_name: str, type_of_network: str = None) -> None: """ Creates a drawing of the network, according to the selected type of network. Args: G (graph): the input graph output_name (string): the output name type_of_network (string): the type of network Returns: None. Just prints the image to a file into the folder data/ """ if type_of_network == "planar": nx.draw_planar(G, with_labels=True) elif type_of_network == "circular": nx.draw_circular(G, with_labels=True) elif type_of_network == "random": nx.draw_random(G, with_labels=True) elif type_of_network == "spectral": nx.draw_random(G, with_labels=True) elif type_of_network == "kamada_kawai": nx.draw_kamada_kawai(G, with_labels=True) elif type_of_network == "spring": nx.draw_spring(G, with_labels=True) elif type_of_network == "shell": nx.draw_shell(G, with_labels=True) else: nx.draw(G, with_labels=True) plt.savefig("images/" + output_name + "network_" + str(type_of_network) + ".png") plt.close()
def visualize_kamada_BMI_sized_colored(G, labeldict, nodesize, color): nx.draw_kamada_kawai(G, labels=labeldict, with_labels=True, node_size=nodesize, node_color=color) plt.show()
def create_plot(min_degree=0, min_freq=0): # fig = plt.figure(figsize=(20, 20)) G = nx.Graph() selected_nodes = node_data[node_data['degree'] >= som1.val] node_id = set(selected_nodes['ID'].values) selected_edges = edge_data[(edge_data['frequency'] >= som2.val) & (edge_data['from'].isin(node_id)) & (edge_data['to'].isin(node_id))] # node for i in range(len(selected_nodes)): G.add_node(selected_nodes.iloc[i]['ID'], name=selected_nodes.iloc[i]['old_name'], state=selected_nodes.iloc[i]['state'], pos=(selected_nodes.iloc[i]['lon'], selected_nodes.iloc[i]['lat'])) # edge for i in range(len(selected_edges)): G.add_edge(selected_edges.iloc[i]['from'], selected_edges.iloc[i]['to']) # node color colors = list(selected_nodes['stateNo'].values) # node size node_size = list(map(lambda x: x * 150, selected_nodes['degree'].values)) # node_size = [] # for i in range(len(selected_nodes)): # node_size.append(len(G[i+1])*15) # edge width edge_width = list(map(lambda x: x * 10, selected_edges['frequency'].values)) # edge color edge_color = selected_edges['frequency'] options = { 'with_labels': 1, # bool(True) # nodelist # list(G.nodes()); draw only specified nodes # edgelist # list(G.edges()); draw only specified edges 'node_size': node_size, # scalar/array(300) 'node_color': colors, # color str/array of floats 'alpha': 0.7, 'cmap': plt.cm.tab10, # colormap for mapping intensities of nodes 'linewidths': 0.5, # line witdth of symbol border 'width': edge_width, # line width of edges 'edge_color': edge_color, # color srt/array of floats 'edge_cmap': plt.cm.Greys, # colormap for mappig intensities of edges # style # edge line style(default:'solid') 'labels': nx.get_node_attributes(G, 'name'), 'font_size': 6, # (12) 'font_color': 'k', 'label': 'test123' # label for graph legend } ax.clear() nx.draw_kamada_kawai(G, ax=ax, **options)
def get_grid(fname, plot=False, render=True, part2=False): with open(fname, 'r') as f: lines = f.readlines() lines = [list(l.strip()) for l in lines] grid = defaultdict(int) arr = np.array(lines) for y, x in np.ndindex(arr.shape): grid[(x, y)] = arr[y, x] if part2: mid_y = (len(lines) - 1) // 2 mid_x = (len(lines[0]) - 1) // 2 replacement = np.array([['@', '#', '@'], ['#', '#', '#'], ['@', '#', '@']]) arr[mid_y - 1:mid_y + 2, mid_x - 1:mid_x + 2] = replacement G = nx.Graph() G.graph['keys_held'] = set() G.graph['name'] = 'root' G.graph['keys'] = {} G.graph['doors'] = {} G.graph['cur_pos'] = None G.graph['starting_points'] = [] for y, x in np.argwhere(arr != '#'): G.add_node(Point(x, y)) #, val=arr[y,x]) for yp, xp in [(y + 1, x), (y - 1, x), (y, x + 1), (y, x - 1)]: try: if arr[yp, xp] != '#': G.add_edge(Point(x, y), Point(xp, yp)) except IndexError as e: pass if arr[y, x] in string.ascii_lowercase: G.graph['keys'][arr[y, x]] = Point(x, y) elif arr[y, x] in string.ascii_uppercase: G.graph['doors'][arr[y, x].lower()] = Point(x, y) if arr[y, x] == '@': G.graph['starting_points'].append(Point(x, y)) G.graph['cur_pos'] = Point(x, y) labels = {n: f'({n.x}, {n.y})' for n in G.nodes()} G.graph['labels'] = labels if plot: nx.draw_kamada_kawai(G, with_labels=True, labels=G.graph['labels']) plt.show() if render: render_graph(G) G.graph['key_pos_to_letter'] = {} for k, v in G.graph['keys'].items(): G.graph['key_pos_to_letter'][v] = k return G
def create2DGraph(n=10, plot_flag=0): # Create lattice graph. Thanks networkx. G = nx.grid_2d_graph(n, n, periodic=False) if plot_flag: nx.draw_kamada_kawai(G) plt.title('Lattice Graph Visualization') plt.show() return G
def draw_graph(G): edge_labels = {(u, v): d['coeff'] for u, v, d in G.edges(data=True)} pos = nx.kamada_kawai_layout(G) nx.draw_networkx_edge_labels(G, pos=pos, edge_labels=edge_labels) nx.draw_networkx_edges(G, pos) nx.draw_networkx_nodes(G, pos, with_labels=True) nx.draw_kamada_kawai(G, with_labels=True)
def draw_graph_to_adjacency_matrix(adjacency_matrix): """ Draws the graph in circular format for easier debugging :param adjacency_matrix: :return: """ dag = nx.MultiDiGraph(adjacency_matrix) nx.draw_kamada_kawai(dag, with_labels=True)
def show_graph(self, title=None, node_size=1000): plt.figure() if title is not None: plt.title(title) labels = {} for n, t in self._graph.nodes(data=True): labels[n] = str(n) + '*' + str(t['type']) + ' ' + str(t['stride']) + ' ' + str(t['num_of_filters']) nx.draw_kamada_kawai(self._graph, labels=labels, node_size=node_size)
def draw(self): """ Draws the graph. """ # plt.figure(figsize=(8, 8)) nx.draw_kamada_kawai(self.G, node_color=list(nx.get_node_attributes(self.G, 'value')), cmap=plt.cm.Reds_r, node_size=50)
assert len(helix_graph.graph) == 10 # Get nucleotides involved in basepairs attribute test_helix_position = 1 test_helix = helix_graph.graph.nodes(data=True)[test_helix_position] print(test_helix) basepairs = test_helix['basepairs'] nucleotides_in_basepairs = sorted(it.chain.from_iterable(basepairs)) nucleotides = test_helix['nucleotides'] assert nucleotides_in_basepairs == nucleotides @pytest.mark.development def test_helix_199(helix_199): print('hsa-mir-199b') print(helix_199.graph.edges()) if __name__ == '__main__': hg = helix_graph() print(hg.hlxDict) hg.annotate_helices() nx.draw_kamada_kawai(hg.graph, with_labels=True) plt.show() g = hg.ctgraph.graph labeldict = {n: f'{n} {d["helix_id"]}' for n, d in hg.ctgraph.graph.nodes(data=True)} print(hg.graph.edges(data=True)) nx.draw_kamada_kawai(hg.ctgraph.graph, with_labels=True, labels=labeldict) plt.show()