NetworkX Skill · Data Ai

NetworkX: The Standard for Python Graph Analysis

Master complex networks with NetworkX.

Analyze 4 distinct graph types using advanced algorithms like PageRank. Optimize your Python graph data structures today.

  • Graph Theory
  • Python
  • Data Science
  • Network Analysis
  • Algorithms

About This Skill

NetworkX is a powerful Python package for analyzing complex networks. It supports 4 main graph types—Graph, DiGraph, MultiGraph, and MultiDiGraph—enabling developers to implement standard algorithms like Dijkstra's and PageRank with ease.

Quick Start

  1. 1Install networkx via pip
  2. 2Import networkx as nx
  3. 3Create a graph and add nodes or edges
Example Command
import networkx as nx; G = nx.Graph(); G.add_edge(1, 2)

Core Capabilities

Graph Creation and Manipulation

Support for 4 graph types including directed, undirected, and multi-edge graphs with custom attributes.

Graph Analysis

Compute centrality measures, find shortest paths, detect communities, and measure clustering coefficients.

Graph Algorithms

Execute standard algorithms like Dijkstra's, PageRank, minimum spanning trees, and maximum flow calculations.

Network Generation

Create synthetic networks using random, scale-free, or small-world models for testing and simulation.

Usage Examples

Input

Find the shortest path between node A and B in a directed graph.

Output

nx.shortest_path(G, source='A', target='B')

Input

Calculate the PageRank of all nodes in a social network graph.

Output

nx.pagerank(G)

Before

Manually iterating through a list of tuples to find connections and building a dictionary map.

After

Using nx.from_edgelist() to instantly create a queryable graph object with built-in analysis methods.

SKILL.md

---
name: networkx
description: "NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs."
license: 3-clause BSD license
metadata:
    skill-author: K-Dense Inc.
risk: unknown
source: "https://github.com/networkx/networkx"
---

# NetworkX

## Overview

NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs. Use this skill when working with network or graph data structures, including social networks, biological networks, transportation systems, citation networks, knowledge graphs, or any system involving relationships between entities.

## When to Use This Skill

Invoke this skill when tasks involve:

- **Creating graphs**: Building network structures from data, adding nodes and edges with attributes
- **Graph analysis**: Computing centrality measures, finding shortest paths, detecting communities, measuring clustering
- **Graph algorithms**: Running standard algorithms like Dijkstra's, PageRank, minimum spanning trees, maximum flow
- **Network generation**: Creating synthetic networks (random, scale-free, small-world models) for testing or simulation
- **Graph I/O**: Reading from or writing to various formats (edge lists, GraphML, JSON, CSV, adjacency matrices)
- **Visualization**: Drawing and customizing network visualizations with matplotlib or interactive libraries
- **Network comparison**: Checking isomorphism, computing graph metrics, analyzing structural properties

## Core Capabilities

### 1. Graph Creation and Manipulation

NetworkX supports four main graph types:
- **Graph**: Undirected graphs with single edges
- **DiGraph**: Directed graphs with one-way connections
- **MultiGraph**: Undirected graphs allowing multiple edges between nodes
- **MultiDiGraph**: Directed graphs with multiple edges

Create graphs by:
```python
import networkx as nx

# Create empty graph
G = nx.Graph()

# Add nodes (can be any hashable type)
G.add_node(1)
G.add_nodes_from([2, 3, 4])
G.add_node

Frequently Asked Questions

FAQ

Is NetworkX compatible with other Python data science tools?
Yes, it integrates seamlessly with Matplotlib for visualization, NumPy for matrix operations, and pandas for data frame conversions.
Who is the target audience for this skill?
Python developers, data scientists, and researchers working with relational data, social networks, or biological systems.
How does NetworkX differ from alternatives like igraph?
NetworkX is written in pure Python, making it highly flexible and easy to install, whereas igraph is C-based and may offer better performance for extremely large graphs.
What programming languages are supported?
This skill specifically supports Python, as NetworkX is a native Python package.
What results can I expect when using this skill?
You can expect efficient modeling of complex relationships and deep structural insights through standard graph metrics and algorithms.

Discussion

Discussion

0 comments
U

Trigger Phrases

Use these phrases to activate this skill in your AI coding assistant:

create a directed graphcalculate shortest pathdetect communities in networkgenerate random graphvisualize networkx graph