Network Analysis
ソーシャルネットワークや組織構造を対象に、ネットワーク構造の分析、コミュニティの特定、中心性の測定、関係性の可視化を行います。
description の原文を見る
Analyze network structures, identify communities, measure centrality, and visualize relationships for social networks and organizational structures
SKILL.md 本文
ネットワーク分析
概要
このスキルは、ネットワーク構造を分析して、コミュニティを特定し、中心性を測定し、影響力のあるノードを検出し、ソーシャルネットワーク、組織構造、相互接続システムの複雑な関係を可視化することができます。
使用タイミング
- ソーシャルネットワークを分析して、影響力のあるユーザーとコミュニティ構造を特定する
- 組織階層図をマッピングして、主要なコネクターやボトルネックを特定する
- 引用ネットワークを研究して、影響力のある研究論文と協力パターンを見つける
- ネットワーク関係と類似性に基づいて推薦システムを構築する
- サプライチェーンネットワークを分析してロジスティクスを最適化し、脆弱性を特定する
- 金融取引のネットワーク分析を通じて詐欺パターンを検出する
ネットワークの概念
- ノード: 個々のエンティティ
- エッジ: 接続/関係
- 次数: 接続数
- 中心性: ノードの重要度測定
- コミュニティ: 密に接続されたグループ
- クラスタリング係数: ローカル密度
主要な指標
- 次数中心性: 接続数
- 媒介中心性: パスの制御
- 近接中心性: 他者への平均距離
- 固有ベクトル中心性: 重要なノードへの接続
- モジュラリティ: コミュニティ構造の強度
Pythonでの実装
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from collections import defaultdict, Counter
import seaborn as sns
# Create sample network (social network)
G = nx.Graph()
# Add nodes with attributes
nodes = [
('Alice', {'role': 'Manager', 'dept': 'Sales'}),
('Bob', {'role': 'Engineer', 'dept': 'Tech'}),
('Carol', {'role': 'Designer', 'dept': 'Design'}),
('David', {'role': 'Engineer', 'dept': 'Tech'}),
('Eve', {'role': 'Analyst', 'dept': 'Sales'}),
('Frank', {'role': 'Manager', 'dept': 'HR'}),
('Grace', {'role': 'Designer', 'dept': 'Design'}),
('Henry', {'role': 'Engineer', 'dept': 'Tech'}),
('Iris', {'role': 'Analyst', 'dept': 'Sales'}),
('Jack', {'role': 'Manager', 'dept': 'Finance'}),
]
for node, attrs in nodes:
G.add_node(node, **attrs)
# Add edges (relationships)
edges = [
('Alice', 'Bob'), ('Alice', 'Carol'), ('Alice', 'Eve'),
('Bob', 'David'), ('Bob', 'Henry'), ('Carol', 'Grace'),
('David', 'Henry'), ('Eve', 'Iris'), ('Frank', 'Jack'),
('Grace', 'Carol'), ('Alice', 'Frank'), ('Bob', 'Carol'),
('Eve', 'Alice'), ('Iris', 'Eve'), ('Jack', 'Frank'),
('Henry', 'David'), ('Carol', 'David'),
]
G.add_edges_from(edges)
print("Network Summary:")
print(f"Nodes: {G.number_of_nodes()}")
print(f"Edges: {G.number_of_edges()}")
print(f"Density: {nx.density(G):.2%}")
# 1. Degree Centrality
degree_centrality = nx.degree_centrality(G)
print("\n1. Degree Centrality (Top 5):")
for node, score in sorted(degree_centrality.items(), key=lambda x: x[1], reverse=True)[:5]:
print(f" {node}: {score:.3f}")
# 2. Betweenness Centrality (control over network)
betweenness_centrality = nx.betweenness_centrality(G)
print("\n2. Betweenness Centrality (Top 5):")
for node, score in sorted(betweenness_centrality.items(), key=lambda x: x[1], reverse=True)[:5]:
print(f" {node}: {score:.3f}")
# 3. Closeness Centrality (average distance to others)
closeness_centrality = nx.closeness_centrality(G)
print("\n3. Closeness Centrality (Top 5):")
for node, score in sorted(closeness_centrality.items(), key=lambda x: x[1], reverse=True)[:5]:
print(f" {node}: {score:.3f}")
# 4. Eigenvector Centrality
try:
eigenvector_centrality = nx.eigenvector_centrality(G, max_iter=100)
print("\n4. Eigenvector Centrality (Top 5):")
for node, score in sorted(eigenvector_centrality.items(), key=lambda x: x[1], reverse=True)[:5]:
print(f" {node}: {score:.3f}")
except:
print("\n4. Eigenvector Centrality: Not converged")
# 5. Community Detection (using modularity)
from networkx.algorithms import community
communities = list(community.greedy_modularity_communities(G))
print(f"\n5. Community Detection:")
print(f"Number of communities: {len(communities)}")
for i, comm in enumerate(communities):
print(f" Community {i+1}: {list(comm)}")
# 6. Network Statistics
degrees = [G.degree(n) for n in G.nodes()]
print(f"\n6. Network Statistics:")
print(f"Average Degree: {np.mean(degrees):.2f}")
print(f"Max Degree: {max(degrees)}")
print(f"Min Degree: {min(degrees)}")
print(f"Clustering Coefficient: {nx.average_clustering(G):.3f}")
print(f"Number of Triangles: {sum(nx.triangles(G).values()) // 3}")
# Visualization
fig, axes = plt.subplots(2, 2, figsize=(15, 12))
# Network layout
pos = nx.spring_layout(G, k=0.5, iterations=50, seed=42)
# 1. Network Graph (colored by degree)
ax = axes[0, 0]
node_colors = [degree_centrality[node] for node in G.nodes()]
nx.draw_networkx_nodes(G, pos, node_color=node_colors, node_size=1000, cmap='YlOrRd', ax=ax)
nx.draw_networkx_edges(G, pos, alpha=0.5, ax=ax)
nx.draw_networkx_labels(G, pos, font_size=8, ax=ax)
ax.set_title('Network Graph (Colored by Degree Centrality)')
ax.axis('off')
# 2. Network Graph (colored by communities)
ax = axes[0, 1]
color_map = []
colors = plt.cm.Set3(np.linspace(0, 1, len(communities)))
node_to_color = {}
for i, comm in enumerate(communities):
for node in comm:
node_to_color[node] = colors[i]
color_map = [node_to_color[node] for node in G.nodes()]
nx.draw_networkx_nodes(G, pos, node_color=color_map, node_size=1000, ax=ax)
nx.draw_networkx_edges(G, pos, alpha=0.5, ax=ax)
nx.draw_networkx_labels(G, pos, font_size=8, ax=ax)
ax.set_title('Network Graph (Colored by Community)')
ax.axis('off')
# 3. Centrality Comparison
ax = axes[1, 0]
centrality_df = pd.DataFrame({
'Degree': degree_centrality,
'Betweenness': betweenness_centrality,
'Closeness': closeness_centrality,
}).head(8)
centrality_df.plot(kind='barh', ax=ax, width=0.8)
ax.set_xlabel('Centrality Score')
ax.set_title('Top 8 Nodes - Centrality Comparison')
ax.legend(loc='lower right')
ax.grid(True, alpha=0.3, axis='x')
# 4. Degree Distribution
ax = axes[1, 1]
degree_sequence = sorted([d for n, d in G.degree()], reverse=True)
degree_count = Counter(degree_sequence)
degrees_unique = sorted(degree_count.keys())
counts = [degree_count[d] for d in degrees_unique]
ax.bar(degrees_unique, counts, color='steelblue', edgecolor='black', alpha=0.7)
ax.set_xlabel('Degree')
ax.set_ylabel('Count')
ax.set_title('Degree Distribution')
ax.grid(True, alpha=0.3, axis='y')
plt.tight_layout()
plt.show()
# 7. Path Analysis
print(f"\n7. Path Analysis:")
try:
shortest_path = nx.shortest_path_length(G, 'Alice', 'Jack')
print(f"Shortest path from Alice to Jack: {shortest_path}")
except nx.NetworkXNoPath:
print("No path exists between nodes")
# 8. Connectivity Analysis
print(f"\n8. Connectivity Analysis:")
print(f"Is connected: {nx.is_connected(G)}")
num_components = nx.number_connected_components(G)
print(f"Number of connected components: {num_components}")
# 9. Similarity Measures
def jaccard_similarity(node1, node2):
neighbors1 = set(G.neighbors(node1)) | {node1}
neighbors2 = set(G.neighbors(node2)) | {node2}
intersection = len(neighbors1 & neighbors2)
union = len(neighbors1 | neighbors2)
return intersection / union if union > 0 else 0
print(f"\n9. Node Similarity (Jaccard):")
print(f"Alice & Bob: {jaccard_similarity('Alice', 'Bob'):.3f}")
print(f"Alice & Jack: {jaccard_similarity('Alice', 'Jack'):.3f}")
# 10. Influence Score (Combination of metrics)
influence_score = {}
for node in G.nodes():
score = (degree_centrality[node] * 0.4 +
betweenness_centrality[node] * 0.3 +
closeness_centrality[node] * 0.3)
influence_score[node] = score
print(f"\n10. Influence Score (Top 5):")
for node, score in sorted(influence_score.items(), key=lambda x: x[1], reverse=True)[:5]:
print(f" {node}: {score:.3f}")
# Summary
print("\n" + "="*50)
print("NETWORK ANALYSIS SUMMARY")
print("="*50)
print(f"Most influential: {max(influence_score, key=influence_score.get)}")
print(f"Most connected: {max(degree_centrality, key=degree_centrality.get)}")
print(f"Network bottleneck: {max(betweenness_centrality, key=betweenness_centrality.get)}")
print(f"Closest to all: {max(closeness_centrality, key=closeness_centrality.get)}")
print("="*50)
中心性測定
- 次数: 直接的な接続のみ
- 媒介: グループ間の橋
- 近接: ネットワークへのアクセス
- 固有ベクトル: 重要なノードに接続
- PageRank: ランダムウォークの確率
コミュニティ検出
- モジュラリティ最適化: 密なグループを検出
- Louvainアルゴリズム: 階層型コミュニティ
- K-clique: 重複するコミュニティ
- スペクトル: 固有値ベース
応用例
- ソーシャルネットワーク分析
- 組織構造
- 引用ネットワーク
- 推薦ネットワーク
- サプライチェーン分析
成果物
- ネットワーク可視化
- 中心性分析
- コミュニティ検出結果
- 接続メトリクス
- 影響力ランキング
- 主要ノードの特定
- ネットワーク統計の概要
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- aj-geddes
- ライセンス
- MIT
- 最終更新
- 不明
Source: https://github.com/aj-geddes/useful-ai-prompts / ライセンス: MIT
関連スキル
superfluid
Superfluidプロトコルおよびそのエコシステムに関するナレッジベースです。Superfluidについて情報を検索する際は、ウェブ検索の前にこちらを参照してください。対応キーワード:Superfluid、CFA、GDA、Super App、Super Token、stream、flow rate、real-time balance、pool(member/distributor)、IDA、sentinels、liquidation、TOGA、@sfpro/sdk、semantic money、yellowpaper、whitepaper
civ-finish-quotes
実質的なタスクが真に完了した際に、文明風の儀式的な引用句を追加します。ユーザーやエージェントが機能追加、リファクタリング、分析、設計ドキュメント、プロセス改善、レポート、執筆タスクといった実際の成果物を完成させるときに、明示的な依頼がなくても使用します。短い返信や小さな修正、未完成の作業には適用しません。
nookplot
Base(Ethereum L2)上のAIエージェント向け分散型調整ネットワークです。エージェントがオンチェーンアイデンティティを登録する、コンテンツを公開する、他のエージェントにメッセージを送る、マーケットプレイスで専門家を雇う、バウンティを投稿・請求する、レピュテーションを構築する、共有プロジェクトで協業する、リサーチチャレンジを解くことでNOOKをマイニングする、キュレーションされたナレッジを備えたスタンドアロンオンチェーンエージェントをデプロイする、またはアグリーメントとリワードで収益を得る場合に利用できます。エージェントネットワーク、エージェント調整、分散型エージェント、NOOKトークン、マイニングチャレンジ、ナレッジバンドル、エージェントレピュテーション、エージェントマーケットプレイス、ERC-2771メタトランザクション、Prepare-Sign-Relay、AgentFactory、またはNookplotが言及された場合にトリガーされます。
web3-polymarket
Polygon上でのPolymarket予測市場取引統合です。認証機能(L1 EIP-712、L2 HMAC-SHA256、ビルダーヘッダー)、注文発注(GTC/GTD/FOK/FAK、バッチ、ポストオンリー、ハートビート)、市場データ(Gamma API、Data API、オーダーブック、サブグラフ)、WebSocketストリーミング(市場・ユーザー・スポーツチャネル)、CTF操作(分割、統合、償却、ネガティブリスク)、ブリッジ機能(入金、出金、マルチチェーン)、およびガスレスリレイトランザクションに対応しています。AIエージェント、自動マーケットメーカー、予測市場UI、またはPolygraph上のPolymarketと統合するアプリケーション構築時に活用できます。
ethskills
Ethereum、EVM、またはブロックチェーン関連のリクエストに対応します。スマートコントラクト、dApps、ウォレット、DeFiプロトコルの構築、監査、デプロイ、インタラクションに適用されます。Solidityの開発、コントラクトアドレス、トークン規格(ERC-20、ERC-721、ERC-4626など)、Layer 2ネットワーク(Base、Arbitrum、Optimism、zkSync、Polygon)、Uniswap、Aave、Curveなどのプロトコルとの統合をカバーします。ガスコスト、コントラクトのデシマル設定、オラクルセキュリティ、リエントランシー、MEV、ブリッジング、ウォレット管理、オンチェーンデータの取得、本番環境へのデプロイ、プロトコル進化(EIPライフサイクル、フォーク追跡、今後の変更予定)といったトピックを含みます。
xxyy-trade
このスキルは、ユーザーが「トークン購入」「トークン売却」「トークンスワップ」「暗号資産取引」「取引ステータス確認」「トランザクション照会」「トークンスキャン」「フィード」「チェーン監視」「トークン照会」「トークン詳細」「トークン安全性確認」「ウォレット一覧表示」「マイウォレット」「AIスキャン」「自動スキャン」「ツイートスキャン」「オンボーディング」「IP確認」「IPホワイトリスト」「トークン発行」「自動売却」「損切り」「利益確定」「トレーリングストップ」「保有者」「トップホルダー」「KOLホルダー」などをリクエストした場合、またはSolana/ETH/BSC/BaseチェーンでXXYYを経由した取引について言及した場合に使用します。XXYY Open APIを通じてオンチェーン取引とデータ照会を実現します。