networkx memo

TL;DR

I often analyzed using networkx, so a brief note I may write an article soon

Fixed spring layout

I want to fix it because a different network is generated every time I write it in spring layout. If you fix random seed of numpy, you can fix the generated network.

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()

Recommended Posts

networkx memo
NetworkX memo (directed graph)
gzip memo
Raspberry-pi memo
Pandas memo
HackerRank memo
Python memo
python memo
graphene memo
pyenv memo
Matplotlib memo
pytest memo
sed memo
Python memo
Install Memo
BeautifulSoup4 memo
python memo
tomcat memo
command memo
Generator memo.
psycopg2 memo
Python memo
SSH memo
Command memo
Memo: rtl8812
pandas memo
Shell memo
Python memo
Pycharm memo
Python memo
[OpenCV] Personal memo
[Python] Memo dictionary
PyPI push memo
tensorflow-gpu introduction memo
LPIC201 learning memo
Jupyter Notebook memo
LPIC304 virtualization memo
ALDA execution memo
python beginner memo (9.2-10)
Linux x memo
Django Learning Memo
ARC # 016 Participation memo
Beautiful Soup memo
LPIC101 study memo
python beginner memo (9.1)
linux (ubuntu) memo
scp command memo
celery / kombu memo
django tutorial memo
Flask basic memo
Linux # Command Memo 1
★ Memo ★ Python Iroha
Gender recognition memo
Image reading memo
[MEMO] [TERMINAL] Alacritty
3D rotation memo (1)
[Python] EDA memo
Python 3 operator memo
H2O.ai Introduction memo
lambda expression memo
[Memo] [terminal] xfce-terminal