LoginSignup
1
1

More than 3 years have passed since last update.

networkxメモ

Posted at

TL;DR

networkxを使って解析することが多かったので簡単にメモ
そのうち記事にするかも

spring layoutの固定

spring layoutで書くと毎回違うネットワークが生成させるので、固定したい。
numpyのrandomseedを固定すれば生成されるネットワークを固定できる。

import numpy as np
import networkx as nx
import matplotlib.pyplot as plt

np.random.seed(10)

G = nx.read_gml("/path/to/gmlfile")
pos = nx.spring_layout(G)
fig, ax = plt.subplots()

nx.draw_networkx_nodes(G, pos, ax=ax)
nx.draw_networkx_edges(G, pos, ax=ax)
plt.show()
1
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
1
1