← ClaudeAtlas

networkxlisted

Build, analyze, and visualize networks and graphs using NetworkX (Python). Use this skill whenever the user wants to: create graphs or networks, analyze graph properties, compute centrality measures, find shortest paths, detect communities, run graph algorithms, convert graphs to/from matrices or dataframes, visualize networks with matplotlib, import/export graph files (GML, GraphML, GEXF, edgelist, etc.), work with directed or undirected graphs, weighted or multigraphs, perform social network analysis, or do any graph theory computation. Trigger on keywords: networkx, graph, network, nodes, edges, adjacency, shortest path, centrality, community detection, spanning tree, flow, clique, PageRank, bipartite, DAG, topology, graph analysis, social network.
SenolIsci/mykg · ★ 2 · Data & Documents · score 78
Install: claude install-skill SenolIsci/mykg
# NetworkX Skill — Create and Manipulate Networks NetworkX (v3.6+) is the standard Python library for graph analysis. This skill covers everything from basic graph creation to advanced algorithms. When in doubt, prefer simple explicit code over clever one-liners — graphs are complex enough on their own. **References:** - [algorithms.md](references/algorithms.md) — Algorithm reference by category (centrality, community, flow, etc.) - [io.md](references/io.md) — File I/O and format conversion reference --- ## 1. Choosing a Graph Class Pick the right class first — it cannot easily be changed after construction. ```python import networkx as nx G = nx.Graph() # undirected, no parallel edges DG = nx.DiGraph() # directed, no parallel edges MG = nx.MultiGraph() # undirected + parallel edges allowed MD = nx.MultiDiGraph() # directed + parallel edges allowed ``` | Need | Class | |---|---| | Social networks, protein interactions | `Graph` | | Web graphs, citation networks, DAGs | `DiGraph` | | Transport networks (multiple routes) | `MultiGraph` | | Dependency graphs with typed edges | `MultiDiGraph` | Convert between types: ```python DG = G.to_directed() # Graph → DiGraph (each edge becomes two arcs) G2 = DG.to_undirected() # DiGraph → Graph ``` --- ## 2. Building Graphs ### Add Nodes Any hashable Python object is a valid node: int, str, tuple, frozenset. ```python G.add_node(1) G.add_node("Alice", age=30, role="engineer") # node with attributes