networkx

Solid

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.

AI & Automation 59 stars 11 forks Updated 3 days ago MIT

Install

View on GitHub

Quality Score: 86/100

Stars 20%
59
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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...

Details

Author
SenolIsci
Repository
SenolIsci/mykg
Created
2 months ago
Last Updated
3 days ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category