3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NetworkX の有向グラフをプロット(netgraph)

Last updated at Posted at 2018-01-22

こんにちは。
networkx の有向グラフをプロットして見ました(図1)。
またnetgraph というものを見つけたので、こちらもプロットして見ました(図2)。矢形が小さいことが少し気になりますが(デフォルト?)。

networkx.jpg nxgraph.jpg
networkx_draw.py
import matplotlib.pyplot as plt
import networkx as nx
n = 5
edges = [(i, (i+1)%n) for i in range(n)]
edges.append((1,0))
G = nx.DiGraph()
G.add_nodes_from(range(n))
G.add_edges_from(edges)
nx.draw_networkx(G)
plt.show()
#
import netgraph
netgraph.draw(G, draw_arrows=True, node_size=7, node_labels=dict([(n,n) for n in G.nodes()]))
plt.show()
$ pip install netgraph
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?