design-architecture
Reviews the current codebase architecture and proposes improvements using four parallel specialist subagents: System Architect, Software Architect, Data…
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
$ npx -y skills add SenolIsci/mykg --skill networkx --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/networkxContext preview
The summary Claude sees to decide when to auto-load this skill.
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
name: networkx description: "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." allowed-tools: Bash Read Write Edit
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:**
---
Pick the right class first — it cannot easily be changed after construction.
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:
DG = G.to_directed() # Graph → DiGraph (each edge becomes two arcs) G2 = DG.to_undirected() # DiGraph → Graph
---
Any hashable Python object is a valid node: int, str, tuple, frozenset.
G.add_node(1)
G.add_node("Alice", age=30, role="engineer") # node with attributes
G.add_nodes_from([2, 3, 4])
G.add_nodes_from([
("Bob", {"age": 25, "role": "designer"}),
("Carol", {"age": 35, "role": "manager"}),
])G.add_edge(1, 2)
G.add_edge("Alice", "Bob", weight=0.9, relation="colleague")
G.add_edges_from([(1, 2), (2, 3), (3, 4)])
G.add_edges_from([
(1, 2, {"weight": 1.5}),
(2, 3, {"weight": 0.8}),
])
G.add_weighted_edges_from([(1, 2, 1.5), (2, 3, 0.8)]) # shorthandFor MultiGraph, `add_edge` returns the edge key (int):
k = MG.add_edge(1, 2, weight=0.5) # k=0 k = MG.add_edge(1, 2, weight=0.75) # k=1 (parallel edge)
G.remove_node(1) G.remove_nodes_from([2, 3]) G.remove_edge(1, 2) G.remove_edges_from([(1, 2), (2, 3)]) G.clear() # remove everything
G = nx.Graph(name="Social Network", created="2025") G.graph["description"] = "Friendship graph"
---
# Size
G.number_of_nodes() # or len(G)
G.number_of_edges() # or G.size()
# Nodes and edges (views, not copies)
list(G.nodes)
list(G.nodes(data=True)) # with attributes
list(G.nodes(data="weight", default=1.0)) # specific attribute
list(G.edges)
list(G.edges(data=True)) # with attributes
list(G.edges(data="weight")) # specific attribute
# Adjacency
list(G.neighbors(1)) # undirected neighbors
list(G.adj[1]) # same, dict-style
G.adj[1][2]["weight"] # edge attribute lookup
# DiGraph-specific
list(DG.successors(n))
list(DG.predecessors(n))
list(DG.in_edges(n))
list(DG.out_edges(n))
# Degree
G.degree(1) # single node
dict(G.degree()) # all nodes → {node: degree}
dict(G.degree(weight="weight")) # weighted degree
# MultiDiGraph
MD.in_degree(n)
MD.out_degree(n)1 in G # node membership (1, 2) in G.edges # edge membership G.has_node(1) G.has_edge(1, 2)
---
# Read node attribute
G.nodes[1]["color"]
# Write node attribute
G.nodes[1]["color"] = "red"
# Read edge attribute
G[1][2]["weight"] # Graph / DiGraph
MG[1][2][0]["weight"] # MultiGraph (key=0)
# Write edge attribute
G[1][2]["weight"] = 4.7
# Bulk set / get with dict or scalar
nx.set_node_attributes(G, {1: "red", 2: "blue"}, name="color")
nx.set_node_attributes(G, 0.0, name="score") # same value for all
nx.set_edge_attributes(G, {(1,2): 1.5, (2,3): 0.8}, name="weight")
colors = nx.get_node_attributes(G, "color") # {node: value}
weights = nx.get_edge_attributes(G, "weight") # {(u,v): value}---
Views are live windows — they reflect changes to the original graph without copying data.
# Node-induced subgraph sub = G.subgraph([1, 2, 3]) # view sub = G.subgraph([1, 2, 3]).copy() # independent copy # Edge-induced subgraph esub = G.edge_subgraph([(1, 2), (2, 3)]) # Filter view (no copy) import networkx as nx heavy = nx.subgraph_view(G, filter_edge=lambda u, v: G[u][v]["weight"] > 0.5) # Reverse a DiGraph R = DG.reverse() # view R = DG.reverse(copy=True) # Add useful structural paths/cycles nx.add_path(G, [10, 11, 12, 13]) nx.add_cycle(G, [20, 21, 22]) nx.add_star(G, [0, 1, 2, 3]) # 0 is the hub
---
nx.complete_graph(5) # K5 nx.complete_bipartite_graph(3, 4) nx.cycle_graph(6) nx.path_graph(5) nx.star_graph(4) # hub + 4 leaves nx.wheel_graph(6) nx.petersen_graph() nx.balanced_tree(r=3, h=2) # 3-ary tree, height 2 nx.barbell_grap
myKG automatically generates a confidence-scored knowledge graph from a set of mixed documents — Markdown, plain text, PDF, Word, PowerPoint, Excel, HTML, and images — grounded in an induced RDFS/OWL ontology.
Reviews the current codebase architecture and proposes improvements using four parallel specialist subagents: System Architect, Software Architect, Data…
Set up and maintain the GitHub Pages site for the mykg repo (SenolIsci/mykg) — a purpose-built pages/ folder (landing page adapted from README.md, blog posts,…