处理网络和图数据需要了解图算法、可视化技术和数据格式。本技能提供关于使用NetworkX在Python中创建、分析和可视化复杂网络的全面指导。
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「networkx」。 Create a graph with 5 nodes connected in a cycle and compute the shortest path from node 1 to node 5
預期結果:
Path found: [1, 2, 3, 4, 5] with length 4
正在使用「networkx」。 Find the node with highest betweenness centrality in a social network
預期結果:
User 'alice' has the highest betweenness centrality (0.45), indicating significant influence in connecting different groups
正在使用「networkx」。 Generate a scale-free network with 100 nodes
預期結果:
Generated Barabasi-Albert graph with 100 nodes and 297 edges using preferential attachment
安全審計
安全All static findings are false positives. The skill is a documentation/reference guide for NetworkX (Python graph library). Static scanner flagged markdown code formatting backticks as 'shell execution' and documentation about file I/O operations as 'filesystem access'. No malicious code, credential access, or command injection exists. The skill provides safe Python graph processing guidance.
風險因素
品質評分
你能建構什麼
分析社交网络关系
构建和分析社交网络图,以识别有影响力的用户、检测社区并查找连接模式。
建模生物网络
创建蛋白质相互作用网络、基因调控网络或神经连接图,用于生物学研究。
优化基础设施路由
查找最短路径、设计高效的交通网络并分析基础设施系统中的连接性。
試試這些提示
如何使用NetworkX创建一个基本图并添加带有属性的节点和边?
在我的图中查找两个节点之间的最短路径,并考虑边权重计算总距离。
计算中心性测量(介数中心性、度中心性、PageRank)以识别我的网络中最有影响力的节点。
使用基于模块度的方法在我的图中检测社区,并用不同颜色可视化每个社区的结果。
最佳實務
- 在生成随机图或布局时设置随机种子(seed=42)以确保可重复性
- 根据边是否是有向的以及是否存在多条边,选择合适的图类型(Graph、DiGraph、MultiGraph)
- 选择高效的文件格式,如用于保留属性的GraphML或用于大型Python对象的pickle
避免
- 避免使用浮点数作为节点标识符,因为存在精度比较问题
- 不要尝试在没有先过滤或聚类的情况下绘制非常大的图(>1000个节点)
- 避免在迭代节点或边时修改图而不先创建副本