networkx
यह क्या करती है
यह टूल जटिल नेटवर्क बनाने, उनका विश्लेषण करने और उन्हें चित्र के रूप में दिखाने में मदद करता है, जैसे सोशल नेटवर्क या ट्रांसपोर्ट नेटवर्क। इससे आप समझ सकते हैं कि अलग-अलग बिंदु आपस में कैसे जुड़े हैं।
कब इस्तेमाल करें
- ✓जब आप समझना चाहते हैं कि सोशल नेटवर्क में लोग एक-दूसरे से कैसे जुड़े हैं।
- ✓जब ट्रांसपोर्ट रूट का नक्शा बनाना और सबसे छोटा रास्ता ढूंढना हो।
- ✓जब अलग-अलग चीज़ों के बीच रिश्तों का ढांचा दिखाना हो।
Skill का लिंक
https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/networkx/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“दोस्ती की सूची से एक सोशल नेटवर्क graph बनाओ और दिखाओ कि किसके सबसे ज़्यादा कनेक्शन हैं।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
आप बिंदुओं (nodes) और उनके बीच के कनेक्शन (edges) का वर्णन करते हैं। फिर टूल एल्गोरिदम की मदद से इस नेटवर्क के बारे में जानकारी निकालता है, जैसे सबसे छोटा रास्ता या हर बिंदु कितना महत्वपूर्ण है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
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.
This skill targets tested NetworkX 3.7 (Python >=3.12, excluding 3.14.1). Several pre-3.0 APIs (nx.info, nx.write_gpickle, nx.read_shp) and the 3.4-era nx.random_tree no longer exist — current replacements are used throughout this skill.
Review sources, executed examples, optional-dependency limits, and reproducibility notes are in references/review.md. Reference snippets are API patterns: supply the stated graph type and input files; they are not one sequential script.
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:
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("protein_A", type='enzyme', weight=1.5)
# Add edges
G.add_edge(1, 2)
G.add_edges_from([(1, 3), (2, 4)])
G.add_edge(1, 4, weight=0.8, relation='interacts')
Reference: See references/graph-basics.md for comprehensive guidance on creating, modifying, examining, and managing graph structures, including working with attributes and subgraphs.
2. Graph Algorithms
NetworkX provides extensive algorithms for network analysis:
Shortest Paths:
For weighted paths and betweenness, weights represent distances/costs: larger values make a route less favorable. Similarity, correlation, or interaction strength needs an explicit scientifically justified conversion before use as distance. Validate the chosen attribute on every edge and use strictly positive distances for weighted betweenness.
# Same distance model for route and length
G = nx.Graph()
G.add_weighted_edges_from([(1, 2, 1), (2, 5, 1), (1, 5, 5)], weight='distance')
path = nx.shortest_path(G, source=1, target=5, weight='distance')
length = nx.shortest_path_length(G, source=1, target=5, weight='distance')
assert path == [1, 2, 5] and length == 2
Centrality Measures:
# Degree centrality
degree_cent = nx.degree_centrality(G)
# Betweenness centrality
betweenness = nx.betweenness_centrality(G)
# PageRank
pagerank = nx.pagerank(G)
Community Detection:
from networkx.algorithms import community
# Specify weight=None for unweighted topology
communities = community.greedy_modularity_communities(G, weight=None)
Connectivity:
# Check connectivity
is_connected = nx.is_connected(G)
# Find connected components
components = list(nx.connected_components(G))
Reference: See references/algorithms.md for worked API patterns for common algorithms including shortest paths, centrality measures, clustering, community detection, flows, matching, tree algorithms, and graph traversal.
3. Graph Generators
Create synthetic networks for testing, simulation, or modeling:
Classic Graphs:
# Complete graph
G = nx.complete_graph(n=10)
# Cycle graph
G = nx.cycle_graph(n=20)
# Known graphs
G = nx.karate_club_graph()
G = nx.petersen_graph()
Random Networks:
…
अक्सर पूछे जाने वाले सवाल
nodes और edges क्या हैं?
Nodes नेटवर्क के अलग-अलग बिंदु होते हैं (जैसे सोशल नेटवर्क में लोग), और edges इन बिंदुओं के बीच के कनेक्शन होते हैं (जैसे दोस्ती)।
क्या मैं असली दुनिया का डेटा इस्तेमाल कर सकता हूँ?
हाँ, आप connection lists, CSV या दूसरी फाइलों से डेटा लोड करके नेटवर्क बना सकते हैं।
क्या टूल नेटवर्क का चित्र बना सकता है?
हाँ, यह नेटवर्क की ग्राफिकल विज़ुअलाइज़ेशन बना सकता है, ताकि उसका ढांचा समझने में आसानी हो।
जानकारी
लेखक का मूल विवरण
Creates, analyzes, and visualizes complex networks and graphs in Python with NetworkX. Use when working with network/graph data structures, computing graph algorithms (shortest paths, centrality, clustering), detecting communities, generating synthetic networks (random, scale-free, small-world), reading/writing graph file formats, or drawing network topologies. Common applications include social,
लोकप्रियता
- GitHub स्टार
- 51k
- रैंकिंग में स्थान
- #3503
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
13c-metabolic-flux
51kकार्बन-13 आइसोटोप ट्रेसिंग डेटा से मेटाबोलिक फ़्लक्स का अनुमान लगाता है। कोशिका के मेटाबॉलिज़्म और बायोकेमिकल मार्गों का विश्लेषण करने के लिए यह उपयोगी है।
adaptyv
51kAdaptyv API का उपयोग करके प्रोटीन कैरेक्टराइज़ेशन प्रयोग डिज़ाइन करता है। लागत का अनुमान लगाने, सीक्वेंस सबमिट करने और लैब के नतीजों पर नज़र रखने में मदद करता है।
aeon
51kटाइम सीरीज़ डेटा पर मशीन लर्निंग के काम करता है। क्रमबद्ध डेटा में वर्गीकरण, पूर्वानुमान, एनोमली डिटेक्शन और पैटर्न खोजने के लिए यह उपयोगी है।
alphagenome
51kजेनेटिक वेरिएंट्स के पहले से गणना किए गए जीनोमिक प्रभाव देखता है। वेरिएंट का जीनोम पर असर समझने के लिए स्कोर और स्पष्टीकरण देता है।
मिलती-जुलती skills
gitcrawl
394kयह आपके एजेंट को GitHub issues और pull requests के सेव आर्काइव में खोजने, मिलते-जुलते मामलों को समूह में रखने और लाइव स्थिति जांचने देती है।
slacrawl
394kयह आपके एजेंट को स्थानीय Slack आर्काइव में संदेश खोजने और गिनने, उसकी ताज़गी जांचने और ज़रूरत पड़ने पर उसे ताज़ा करने देती है।
goplaces
394kयह आपके एजेंट को Google Places से जगहें खोजने, उनका विवरण और समीक्षाएं पाने, और जगह के नाम हल करने में मदद करती है, स्क्रिप्ट के लिए JSON आउटपुट के साथ।