0
현재 세 쌍의 양식 (node1, node2, weight_of_edge)이 있습니다. 레이아웃 사이에 모서리가있는 노드가 가까이에 모일 수 있도록 줄을 그릴 수있는 방법이 있습니까?networkx layout
현재 세 쌍의 양식 (node1, node2, weight_of_edge)이 있습니다. 레이아웃 사이에 모서리가있는 노드가 가까이에 모일 수 있도록 줄을 그릴 수있는 방법이 있습니까?networkx layout
네트워크 생성 및 조작을위한 많은 도구를 제공하는 NetworkX 라이브러리를 살펴 봐야합니다. 세 쌍둥이의 목록을 기반으로
기본 예 :
list_of_triplets = [("n1", "n2", 4),
("n3", "n4", 1),
("n5", "n6", 2),
("n7", "n8", 4),
("n1", "n7", 4),
("n2", "n8", 4),
("n8", "n9", 6),
("n4", "n9", 12),
("n4", "n6", 1),
("n2", "n7", 4),
("n1", "n8", 4)]
# The line below in the code change the list in a format that take
# a weight argument in a dictionary, to be computed by NetworkX
formatted_list = [(node[0], node[1], {"weight":node[2]}) for node in list_of_triplets]
그래프를 그리려면
import matplotlib.pyplot as plt
import networkx as nx
G = nx.Graph()
G.add_edges_from(formatted_list)
nx.draw(G)
plt.show()
나는하기 matplotlib에서 이러한 기능을 인식하지입니다. 이를 제공하는 매우 강력한 네트워크 시각화 도구가 있습니다. 예를 들어 [Cytoscape] (http://www.cytoscape.org/)를보십시오. –