감동, 마음이 움직이는 것

[python] making a directed network using networkx 본문

Tips (Utility, Computer Language, and etc.)

[python] making a directed network using networkx

Struggler J. 2020. 6. 21. 22:26

https://networkx.github.io/documentation/stable/reference/classes/digraph.html

 

DiGraph—Directed graphs with self loops — NetworkX 2.4 documentation

incoming_graph_data (input graph (optional, default: None)) – Data to initialize graph. If None (default) an empty graph is created. The data can be any format that is supported by the to_networkx_graph() function, currently including edge list, dict of

networkx.github.io

https://networkx.github.io/documentation/stable/auto_examples/drawing/plot_directed.html

 

Directed Graph — NetworkX 2.4 documentation

© Copyright 2004-2019, NetworkX Developers Last updated on Oct 17, 2019.

networkx.github.io

plot은 안해봤는데 어쨌든 가장 간단하게는 

G = nx.DiGraph()

G.add_node(node_name) #노드를 하나씩 넣어줄 때

G.add_nodes_from(range(10000)) # listt만들어서 넣어주기만 하면 list로도 넣어줄 수 있다.

G.add_edge(n1, n2) # n1으로부터 n2로 나가는 링크하나를 더해준다.

G.add_edges_from([(n1, n2), (n2, n3)]) #마찬가지로 list로 추가 가능하고 이때 링크를 순서쌍으로 넣어줘야 한다.