networkx-graph-analysis について
networkx-graph-analysisは、PythonのNetworkXでグラフを作成・操作・分析するためのスキルガイドです。関係データを扱う研究者や分析者向けに、アルゴリズム、データ形式、可視化を取り上げます。
主な機能
- 01無向・有向・多重グラフ構造
- 02中心性・経路・連結性の分析
- 03コミュニティ検出とグラフ生成
- 04グラフデータの入出力と可視化
活用シーン
- 01ソーシャルネットワークの重要ノード特定
- 02生物学的相互作用ネットワークの分析
- 03交通ネットワークの経路計算
- 04シミュレーション用の合成グラフ生成
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ jaechang-hits/ sciagent-skills --skill networkx-graph-analysisインストール後、Claude Code で/networkx-graph-analysisを入力して読み込まれたか確認します。
同梱ファイルreferences/algorithms_generators.mdreferences/io_visualization.md
詳細
NetworkX グラフ分析
概要
NetworkX は、複雑なネットワークやグラフの作成、操作、分析を行うための Python ライブラリです。無向グラフ、有向グラフ、マルチエッジグラフのデータ構造に加え、包括的なグラフアルゴリズム、生成器、入出力ユーティリティを提供します。ソーシャルネットワーク、生物学的相互作用ネットワーク、交通システム、引用グラフなど、エンティティ間のペア単位の関係を扱うあらゆる分野で NetworkX を使用できます。
使用する場面
- タンパク質間相互作用ネットワーク、遺伝子制御ネットワーク、代謝経路を分析する
- 中心性指標(次数、媒介中心性、PageRank)を計算して重要なノードを特定する
- 交通ネットワークや通信ネットワークで最短経路または最適なルートを見つける
- ソーシャルネットワークや共発現データでコミュニティまたはクラスターを検出する
- シミュレーションや帰無モデル向けに合成ネットワーク(スケールフリー、小世界、ランダム)を生成する
- 標準形式(GraphML、GML、エッジリスト、JSON)でグラフデータを読み書きする
- ノード/エッジ属性をマッピングしてネットワーク構造を可視化する
- グラフの特性(連結性、平面性、同型性、DAG 構造)を確認する
- 大規模グラフ(ノード数 100K 以上)で速度が重要な場合は、代わりに
igraphまたはgraph-toolを使用する - 10 億エッジ規模のグラフや GPU アクセラレーションによる分析には、OpenMP を使用する
graph-toolまたはcuGraphを使用する - グラフニューラルネットワークやグラフ上のディープラーニングには、
torch-geometric-graph-neural-networksを使用する
前提条件
- Python パッケージ:
networkx、matplotlib、scipy、pandas、numpy - オプション:
pydotまたはpygraphviz(Graphviz レイアウト)
pip install networkx matplotlib scipy pandas numpy
クイックスタート
import networkx as nx
# Create a graph and add edges with weights
G = nx.karate_club_graph()
print(f"Nodes: {G.number_of_nodes()}, Edges: {G.number_of_edges()}")
# Nodes: 34, Edges: 78
# Compute centrality and find most central node
bc = nx.betweenness_centrality(G)
top_node = max(bc, key=bc.get)
print(f"Most central node: {top_node}, betweenness: {bc[top_node]:.3f}")
# Detect communities
from networkx.algorithms import community
comms = community.greedy_modularity_communities(G)
print(f"Communities found: {len(comms)}")
コア API
モジュール 1:グラフの作成と種類
import networkx as nx
# Undirected graph (most common)
G = nx.Graph()
G.add_node("protein_A", type="kinase", weight=1.5)
G.add_nodes_from(["protein_B", "protein_C"])
G.add_edge("protein_A", "protein_B", weight=0.9, interaction="phosphorylation")
G.add_edges_from([("protein_B", "protein_C"), ("protein_A", "protein_C")])
print(f"Nodes: {G.number_of_nodes()}, Edges: {G.number_of_edges()}")
# Nodes: 3, Edges: 3
# Directed graph (gene regulation, citations)
D = nx.DiGraph()
D.add_edges_from([("TF1", "geneA"), ("TF1", "geneB"), ("TF2", "geneA")])
print(f"TF1 out-degree: {D.out_degree('TF1')}") # 2
# MultiGraph (multiple relationship types between same nodes)
M = nx.MultiGraph()
M.add_edge("A", "B", key="binding", affinity=0.8)
M.add_edge("A", "B", key="regulation", effect="inhibition")
print(f"Edges between A-B: {M.number_of_edges('A', 'B')}") # 2
モジュール 2:ノードとエッジの操作
import networkx as nx
G = nx.karate_club_graph()
# Query structure
print(f"Degree of node 0: {G.degree(0)}")
print(f"Neighbors of node 0: {list(G.neighbors(0))[:5]}")
print(f"Has edge 0-1: {G.has_edge(0, 1)}")
# Set and get attributes
G.nodes[0]["role"] = "instructor"
nx.set_node_attributes(G, {0: "high", 33: "high"}, "importance")
G[0][1]["weight"] = 0.95
# Iterate with data
for u, v, data in G.edges(data=True):
if "weight" in data:
print(f" Edge {u}-{v}: weight={data['weight']}")
break
# Subgraphs (returns read-only view; use .copy() for mutable)
H = G.subgraph([0, 1, 2, 3, 4, 5]).copy()
print(f"Subgraph: {H.number_of_nodes()} nodes, {H.number_of_edges()} edges")
モジュール 3:グラフ分析(中心性)
import networkx as nx
G = nx.karate_club_graph()
degree_c = nx.degree_centrality(G)
between_c = nx.betweenness_centrality(G, weight="weight")
# For large graphs, approximate: nx.betweenness_centrality(G, k=100)
close_c = nx.closeness_centrality(G)
eigen_c = nx.eigenvector_centrality(G, max_iter=1000)
pr = nx.pagerank(G, alpha=0.85)
# Compare top nodes across measures
for name, metric in [("Degree", degree_c), ("Betweenness", between_c),
("Closeness", close_c), ("PageRank", pr)]:
top = max(metric, key=metric.get)
print(f"{name:12s}: top node={top}, score={metric[top]:.4f}")
モジュール 4:経路と連結性
import networkx as nx
G = nx.karate_club_graph()
# Shortest path
path = nx.shortest_path(G, source=0, target=33)
length = nx.shortest_path_length(G, source=0, target=33)
print(f"Shortest path 0->33: {path} (length {length})")
print(f"Average shortest path length: {nx.average_shortest_path_length(G):.3f}")
# Connected components
print(f"Connected: {nx.is_connected(G)}")
components = list(nx.connected_components(G))
print(f"Components: {len(components)}, largest: {len(max(components, key=len))}")
# For directed graphs: strong/weak connectivity
D = nx.DiGraph([(0,1),(1,2),(2,0),(3,4)])
print(f"Strongly connected: {list(nx.strongly_connected_components(D))}")
# Connectivity measures
print(f"Node connectivity: {nx.node_connectivity(G)}")
print(f"Edge connectivity: {nx.edge_connectivity(G)}")
モジュール 5:コミュニティ検出
ネットワークを、密につながったグループに分割します。
import networkx as nx
from networkx.algorithms import community
import itertools
G = nx.karate_club_graph()
# Greedy modularity maximization
comms_greedy = community.greedy_modularity_communities(G)
mod_score = community.modularity(G, comms_greedy)
print(f"Greedy: {len(comms_greedy)} communities, modularity={mod_score:.4f}")
# Label propagation (fast, non-deterministic)
comms_lpa = community.label_propagation_communities(G)
print(f"Label propagation: {len(list(comms_lpa))} communities")
# Girvan-Newman (hierarchical, edge betweenness removal)
gn = community.girvan_newman(G)
# Get first level of partition
first_level = next(gn)
print(f"Girvan-Newman first split: {len(first_level)} groups")
print(f" Sizes: {[len(c) for c in first_level]}")
モジュール 6:入出力とシリアライズ
import networkx as nx
import pandas as pd
import json
G = nx.karate_club_graph()
# Edge list (simple text format)
nx.write_edgelist(G, "karate.edgelist")
G_loaded = nx.read_edgelist("karate.edgelist", nodetype=int)
# GraphML (preserves all attributes, XML-based)
nx.write_graphml(G, "karate.graphml")
G_xml = nx.read_graphml("karate.graphml")
# JSON (node-link format, web-friendly for d3.js)
data = nx.node_link_data(G)
with open("karate.json", "w") as f:
json.dump(data, f)
# Pandas integration
df = pd.DataFrame({"source": [1,2,3], "target": [2,3,4], "weight": [0.5,1.0,0.75]})
G_pd = nx.from_pandas_edgelist(df, "source", "target", edge_attr="weight")
df_out = nx.to_pandas_edgelist(G_pd)
print(f"Pandas round-trip: {len(df_out)} edges")
# NumPy/SciPy matrices
A = nx.to_numpy_array(G)
print(f"Adjacency matrix shape: {A.shape}")
A_sparse = nx.to_scipy_sparse_array(G, format="csr") # Memory-efficient
モジュール 7:可視化
import networkx as nx
import matplotlib.pyplot as plt
G = nx.karate_club_graph()
pos = nx.spring_layout(G, seed=42)
# Color by degree, size by betweenness centrality
bc = nx.betweenness_centrality(G)
fig, ax = plt.subplots(figsize=(10, 8))
nx.draw(G, pos=pos, ax=ax,
node_color=[G.degree(n) for n in G.nodes()], cmap=plt.cm.viridis,
node_size=[3000 * bc[n] + 100 for n in G.nodes()],
edge_color="gray", alpha=0.8, with_labels=True, font_size=8)
plt.tight_layout()
plt.savefig("network.png", dpi=300, bbox_inches="tight")
plt.savefig("network.pdf", bbox_inches="tight") # Vector format
print("Saved network.png and network.pdf")
モジュール 8:生成器
import networkx as nx
# Erdos-Renyi random graph: n nodes, edge probability p
G_er = nx.erdos_renyi_graph(n=200, p=0.05, seed=42)
print(f"ER: {G_er.number_of_nodes()} nodes, {G_er.number_of_edges()} edges")
# Barabasi-Albert scale-free (power-law degree distribution)
G_ba = nx.barabasi_albert_graph(n=200, m=3, seed=42)
# Watts-Strogatz small-world
G_ws = nx.watts_strogatz_graph(n=200, k=6, p=0.1, seed=42)
print(f"WS clustering: {nx.average_clustering(G_ws):.3f}")
# Stochastic block model (community structure)
sizes, probs = [50, 50, 50], [[0.25,0.05,0.02],[0.05,0.35,0.07],[0.02,0.07,0.40]]
G_sbm = nx.stochastic_block_model(sizes, probs, seed=42)
# Built-in datasets and classic graphs
G_karate = nx.karate_club_graph() # Zachary's karate club
G_grid = nx.grid_2d_graph(5, 7) # 2D lattice
G_tree = nx.random_tree(n=50, seed=42) # Random tree
G_geo = nx.random_geometric_graph(n=100, radius=0.2, seed=42)
# See references/algorithms_generators.md for full generator catalog
主要な概念
グラフの種類
| クラス | 有向 | マルチエッジ | 自己ループ | 使用例 |
|---|---|---|---|---|
Graph | いいえ | いいえ | はい | 無向ネットワーク:ソーシャルネットワーク、PPI |
DiGraph | はい | いいえ | はい | 遺伝子制御、引用、ウェブ |
MultiGraph | いいえ | はい | はい | 複数の関係の種類 |
MultiDiGraph | はい | はい | はい | ルートを含む交通ネットワーク |
属性のパターン
属性は、グラフ、ノード、エッジの各レベルで辞書として保存されます。
import networkx as nx
G = nx.Graph(name="example") # Graph-level attribute
G.add_node(1, label="hub", weight=1.5) # Node attributes
G.add_edge(1, 2, weight=0.8, type="ppi") # Edge attributes
# Bulk set/get
nx.set_node_attributes(G, {1: "red", 2: "blue"}, "color")
colors = nx.get_node_attributes(G, "color") # {1: 'red', 2: 'blue'}
レイアウトアルゴリズム
| レイアウト | 関数 | 最適な用途 |
|---|---|---|
| スプリング(力学ベース) | spring_layout(G, seed=42) | 一般的なネットワーク |
| 円形 | circular_layout(G) | 正則グラフ、サイクル |
| Kamada-Kawai | kamada_kawai_layout(G) | 小~中規模のネットワーク |
| スペクトル | spectral_layout(G) | クラスターの強調 |
| シェル(同心円) | shell_layout(G, nlist=[[...],[...]]) | 階層型/階層的な構造 |
| 平面 | planar_layout(G) | 平面グラフのみ |
一般的なワークフロー
ワークフロー 1:ソーシャルネットワーク分析
目標:影響力のある人物を特定し、コミュニティを検出して可視化します。
import networkx as nx
import matplotlib.pyplot as plt
from networkx.algorithms import community
# Step 1: Load network and basic stats
G = nx.karate_club_graph()
print(f"Network: {G.number_of_nodes()} actors, {G.number_of_edges()} ties")
print(f"Density: {nx.density(G):.4f}, Clustering: {nx.average_clustering(G):.4f}")
# Step 2: Identify influential nodes
bc = nx.betweenness_centrality(G)
top_bc = sorted(bc.items(), key=lambda x: x[1], reverse=True)[:5]
print("Top 5 by betweenness:", [(n, f"{s:.3f}") for n, s in top_bc])
# Step 3: Detect communities
comms = community.greedy_modularity_communities(G)
print(f"Communities: {len(comms)}, modularity: {community.modularity(G, comms):.4f}")
# Step 4: Visualize with community coloring
pos = nx.spring_layout(G, seed=42)
fig, ax = plt.subplots(figsize=(10, 8))
for i, comm in enumerate(comms):
nx.draw_networkx_nodes(G, pos, nodelist=list(comm), ax=ax,
node_color=[plt.cm.Set2(i)]*len(comm), node_size=400)
nx.draw_networkx_edges(G, pos, ax=ax, alpha=0.3)
nx.draw_networkx_labels(G, pos, ax=ax, font_size=8)
plt.axis("off")
plt.tight_layout()
plt.savefig("social_network_analysis.png", dpi=300, bbox_inches="tight")
print("Saved social_network_analysis.png")
ワークフロー 2:生物学的相互作用ネットワーク
目標:表形式のデータから PPI ネットワークを構築し、トポロジーを分析してハブタンパク質を特定します。
import networkx as nx
import pandas as pd
# Step 1: Load interaction data from DataFrame
interactions = pd.DataFrame({
"protein_a": ["TP53","TP53","BRCA1","BRCA1","MDM2","ATM","ATM","CHEK2","RB1","CDK2"],
"protein_b": ["MDM2","BRCA1","ATM","CHEK2","RB1","CHEK2","BRCA2","CDC25A","CDK2","CCNA2"],
"score": [0.99, 0.95, 0.92, 0.88, 0.91, 0.97, 0.85, 0.90, 0.87, 0.93]
})
G = nx.from_pandas_edgelist(interactions, "protein_a", "protein_b",
edge_attr="score")
print(f"PPI network: {G.number_of_nodes()} proteins, {G.number_of_edges()} interactions")
# Step 2: Network statistics
print(f"Connected: {nx.is_connected(G)}")
print(f"Diameter: {nx.diameter(G)}")
print(f"Avg path length: {nx.average_shortest_path_length(G):.2f}")
print(f"Transitivity: {nx.transitivity(G):.4f}")
# Step 3: Hub identification (multiple centrality measures)
degree_c = nx.degree_centrality(G)
between_c = nx.betweenness_centrality(G)
close_c = nx.closeness_centrality(G)
results = pd.DataFrame({
"protein": list(G.nodes()),
"degree_centrality": [degree_c[n] for n in G.nodes()],
"betweenness": [between_c[n] for n in G.nodes()],
"closeness": [close_c[n] for n in G.nodes()],
}).sort_values("betweenness", ascending=False)
print("\nHub proteins:")
print(results.head(5).to_string(index=False))
# Step 4: Export for downstream analysis
nx.write_graphml(G, "ppi_network.graphml")
results.to_csv("protein_centrality.csv", index=False)
print("Exported ppi_network.graphml and protein_centrality.csv")
主なパラメーター
| パラメーター | モジュール | デフォルト | 範囲/選択肢 | 効果 |
|---|---|---|---|---|
weight | Paths/Centrality | None | エッジ属性名 | 経路/中心性の計算に重み付きエッジを使用します |
alpha | pagerank | 0.85 | 0.0-1.0 | 減衰係数です。値が小さいほど、分布はより均一になります |
k | betweenness_centrality | None | int | 大規模グラフで近似する際に、k 個のノードをサンプリングします |
max_iter | eigenvector_centrality | 100 | int | 収束までの最大反復回数です |
seed | Generators/Layouts | None | int | 再現性を確保するための乱数シードです |
n / p / m | ER/BA generators | varies | int/float | ノード数、エッジ確率、新しいノードごとのエッジ数です |
k / p | Watts-Strogatz | varies | int/float | 近傍ノード数、エッジの再配線確率です |
nodetype | read_edgelist | str | int、float、str | ノード識別子の型変換です |
edge_attr | from_pandas_edgelist | None | 列名 | DataFrame から取り込むエッジ属性の列です |
format | to_scipy_sparse_array | "csc" | "csr"、"csc"、"coo" | 疎行列の形式です |
ベストプラクティス
-
再現可能なジェネレーターとレイアウトには、必ず乱数シードを設定します:
erdos_renyi_graph()とspring_layout()の両方でseed=42を指定します。 -
大規模グラフでは近似アルゴリズムを使用します:
nx.betweenness_centrality(G, k=500)は、すべてのペアではなく k 個のノードをサンプリングします。 -
一括データ読み込みでは、手動の
add_edgeループよりfrom_pandas_edgelistを優先します。属性を適切に処理でき、より高速です。 -
変更を加える前にサブグラフをコピーします:
G.subgraph(nodes)は読み取り専用ビューを返します。変更可能な独立したグラフにするには.copy()を呼び出します。 -
すべてのノード/エッジ属性を保持するには、永続ストレージに GraphML または GML を使用します。エッジリストでは、明示的に処理しない限りメタデータが失われます。
-
グラフの型は明示的に変換します:
D.to_undirected()(DiGraph -> Graph)、nx.Graph(M)(MultiGraph -> Graph、複数のエッジを統合)。 -
大規模な隣接行列のエクスポートには疎行列を使用します:
to_scipy_sparse_array()はto_numpy_array()よりもはるかにメモリ効率に優れています。 -
アンチパターン --
nx.info()は使用しないでください:非推奨です。代わりにG.number_of_nodes()、G.number_of_edges()、nx.density(G)を直接使用します。 -
アンチパターン -- ノードの順序を前提にしないでください:アルゴリズムによって、結果が異なる順序で返される場合があります。常に位置ではなくノードキーでインデックスを指定します。
よく使うレシピ
レシピ:最小全域木
最小全域木を抽出し、元のグラフと比較します。
import networkx as nx
# Create weighted graph
G = nx.erdos_renyi_graph(50, 0.15, seed=42)
for u, v in G.edges():
G[u][v]["weight"] = round(nx.utils.py_random_state(42).random(), 2)
mst = nx.minimum_spanning_tree(G, weight="weight")
print(f"Original: {G.number_of_edges()} edges")
print(f"MST: {mst.number_of_edges()} edges")
total_weight = sum(d["weight"] for _, _, d in mst.edges(data=True))
print(f"MST total weight: {total_weight:.2f}")
レシピ:グラフ彩色とクリーク
クリークを見つけ、グラフ彩色を計算します。
import networkx as nx
G = nx.karate_club_graph()
# Find all maximal cliques
cliques = list(nx.find_cliques(G))
print(f"Maximal cliques: {len(cliques)}")
largest_clique = max(cliques, key=len)
print(f"Largest clique size: {len(largest_clique)}, nodes: {largest_clique}")
# Greedy graph coloring
coloring = nx.greedy_color(G, strategy="largest_first")
n_colors = max(coloring.values()) + 1
print(f"Chromatic number (greedy upper bound): {n_colors}")
レシピ:DAG とトポロジカルソート
有向非巡回グラフを構築し、実行順序を見つけます。
import networkx as nx
# Task dependency DAG
D = nx.DiGraph()
D.add_edges_from([
("download_data", "preprocess"),
("download_data", "validate"),
("preprocess", "analyze"),
("validate", "analyze"),
("analyze", "visualize"),
("analyze", "report"),
("visualize", "report"),
])
print(f"Is DAG: {nx.is_directed_acyclic_graph(D)}")
order = list(nx.topological_sort(D))
print(f"Execution order: {order}")
# Find all paths from start to end
paths = list(nx.all_simple_paths(D, "download_data", "report"))
print(f"Paths to report: {len(paths)}")
for p in paths:
print(f" {' -> '.join(p)}")
トラブルシューティング
| 問題 | 原因 | 解決策 |
|---|---|---|
NetworkXError: Graph is not connected | アルゴリズムが連結グラフを必要とします | 最大連結成分を抽出します:G.subgraph(max(nx.connected_components(G), key=len)).copy() |
PowerIterationFailedConvergence | 固有ベクトル/PageRank が収束しませんでした | max_iter を増やす(例:1000)か、非連結成分がないか確認します |
| 中心性の計算が非常に遅い | 大規模グラフでは計算量が O(n*m) です | サンプリングに k パラメーターを使います:betweenness_centrality(G, k=500) |
nx.NetworkXNotImplemented | グラフの種類に対応するアルゴリズムがありません | グラフの種類を変換します:G.to_undirected() または G.to_directed() |
| 大規模グラフでメモリエラーが発生する | 隣接行列が密です | to_numpy_array() の代わりに to_scipy_sparse_array() を使います |
| ファイルから読み込んだノード ID が文字列になる | read_edgelist の既定値は str です | nodetype=int を渡します:nx.read_edgelist(f, nodetype=int) |
| コミュニティ検出が frozenset を返す | コミュニティの通常の戻り値の型です | 変換します:[list(c) for c in communities] |
| 生成したグラフに自己ループがある | Configuration model は自己ループを許可します | 削除します:G.remove_edges_from(nx.selfloop_edges(G)) |
| 可視化が煩雑すぎる | ノード/エッジが多すぎます | 部分グラフに絞り、alpha を調整し、図のサイズを大きくするか、インタラクティブツール(Plotly、PyVis)を使います |
バンドルされたリソース
元のエントリから移行しました(スタブ:メインファイル 436 行+5 つのリファレンスファイルにまたがる 2,014 行、メイン/合計の比率=17.8%)。
references/algorithms_generators.md
対象:探索(DFS/BFS)、サイクル、クリーク、グラフ彩色、同型性、マッチング/被覆、木のアルゴリズム(MST の各種手法)の詳細なアルゴリズムパラメーター。ジェネレーターの完全なカタログ:古典的グラフ、格子/グリッド、木、二部グラフ、次数列、グラフ演算(和、合成、補グラフ、積)。 本文内に移動:主要アルゴリズム(中心性、パス、連結性、コミュニティ、フロー)→ Core API Modules 3-5。主要ジェネレーター(ER、BA、WS、SBM)→ Module 8。 省略:A* のヒューリスティックのカスタマイズ、Bellman-Ford の負の重みについては、公式ドキュメントを参照してください。
元ファイルの扱い:
algorithms.md(383 行):主要アルゴリズムは Core API Modules 3-5 と Recipes に移動しました。残り(探索、クリーク、彩色、同型性、マッチング、サイクル、木)→ このリファレンス。generators.md(378 行):主要ジェネレーターは Module 8 に移動しました。完全なカタログ(古典的グラフ、格子、木、二部グラフ、次数列、演算子)→ このリファレンス。
references/io_visualization.md
対象:すべての I/O 形式(隣接リスト、GEXF、Pajek、LEDA、Cytoscape JSON、DOT/Graphviz、Matrix Market、CSV、データベース/SQL、gzip 圧縮)。形式の選択ガイド。高度な可視化:Plotly によるインタラクティブ表示、PyVis の HTML、Graphviz のレイアウト、3D ネットワーク、二部グラフレイアウト、コミュニティの色分け、部分グラフの強調表示、複数パネルの図、エッジラベル、有向矢印。
本文内に移動:主要な I/O(エッジリスト、GraphML、JSON、pandas、NumPy/SciPy)→ Module 6。基本的な matplotlib → Module 7。
省略:write_gpickle/read_gpickle(非推奨)、read_shp/write_shp(NetworkX 3.0 で削除済み。geopandas を使用してください)。
元ファイルの扱い:
io.md(441 行):主要な形式は Module 6 に移動しました。残りの形式と形式の選択ガイド→ このリファレンス。visualization.md(529 行):基本的な matplotlib は Module 7 に移動しました。高度な手法(Plotly、PyVis、3D、二部グラフ、コミュニティの色分け)→ このリファレンス。
完全に統合された元ファイル
graph-basics.md(283 行):全内容をメインの SKILL.md に統合しました。グラフの種類→ Key Concepts。ノード/エッジの操作、属性、部分グラフ→ Core API Modules 1-2。診断→ Common Workflows。メモリ/浮動小数点に関する考慮事項→ Best Practices + Troubleshooting。省略:nx.info()(非推奨)。
関連スキル
- torch-geometric-graph-neural-networks -- グラフ構造データのノード/グラフ分類やリンク予測に用いるグラフニューラルネットワーク(GCN、GAT、GraphSAGE)
- matplotlib-scientific-plotting -- NetworkX に組み込まれている
nx.drawを超える高度な図のカスタマイズ - plotly-interactive-plots -- ホバー、ズーム、パンに対応したインタラクティブなネットワークプロット
- pandas(予定) -- グラフ構築前にエッジ/ノードデータを準備するための DataFrame 操作
- scipy(予定) -- NetworkX 内部で使用される疎行列操作と数値アルゴリズム
参考資料
- NetworkX ドキュメント -- 公式ドキュメントと API リファレンス
- NetworkX チュートリアル -- 公式の入門ガイド
- NetworkX GitHub -- ソースコードと課題トラッカー
- NetworkX ギャラリー -- 可視化を含むサンプルギャラリー
- Hagberg, A., Schult, D., & Swart, P.(2008). NetworkX を使用したネットワーク構造、ダイナミクス、機能の探究. SciPy 2008.