help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back

Social Network Analysis Visualization - Complete Documentation | NetworkX | Plotly | Network Visualization | Community Detection | Centrality Measures | Graph Analysis | Path Analysis

Complete Documentation & Project Details for Social Network Analysis Visualization with NetworkX and Plotly - Interactive 2D/3D Network Graphs, Community Detection (Louvain algorithm), Centrality Measures (Degree, Betweenness, Closeness, Eigenvector, PageRank), Network Metrics Dashboard, Edge Analysis, Shortest Path Visualization, Subgraph Extraction, Network Generation (random, scale-free, small-world), Path Analysis, Key Node Identification, Network Resilience Analysis, Network Comparison, and Data Export. Perfect for Analyzing Relationships, Network Structures, Social Networks, and Graph Analysis. Features 1 Comprehensive Jupyter Notebook and 6 Python Modules for Network Analysis.

Social Network Analysis Visualization - Project Description | NetworkX | Plotly | Network Visualization | Community Detection

This project creates comprehensive Social Network Analysis Visualization using NetworkX and Plotly for network visualization and graph analysis. The project includes interactive 2D/3D network graphs with zoom and pan functionality, community detection using the Louvain algorithm with color-coded communities, centrality measures (Degree, Betweenness, Closeness, Eigenvector, PageRank) for identifying key nodes, network metrics dashboard with density, clustering coefficient, and degree distribution, edge analysis with edge weights and betweenness visualization, shortest path visualization to find and visualize paths between nodes, subgraph extraction for analyzing specific network components, network generation (random, scale-free, small-world, complete, star, ring, grid, community networks), path analysis with average path length and network diameter, key node identification by various centrality metrics, network resilience analysis to test network robustness, network comparison side-by-side, and data export (CSV, JSON, PNG, PDF, SVG, HTML). Perfect for analyzing relationships, network structures, social networks, and graph analysis.

The Social Network Analysis Visualization project features 1 comprehensive Jupyter notebook (network_analysis.ipynb) covering basic network graphs, community detection, centrality measures, path analysis, and advanced features. The project includes 6 Python modules (network_analysis.py for main analysis, network_visualizer.py for visualization, network_generator.py for network generation, advanced_analysis.py for advanced features, export_utils.py for export functionality, and utils.py for utility functions). Built with Python 3.8+, NetworkX 3.0+, Plotly 5.17.0+, Pandas 2.0.0+, NumPy 1.24.0+, Jupyter 1.0.0+, scipy 1.10.0+, matplotlib 3.7.0+, python-louvain 0.16+ (for community detection), and optional kaleido 0.2.1+ for image export. The project supports network data loading from CSV files and network generation functions for various network types.

Social Network Analysis Screenshots | NetworkX Network Graphs | Interactive Network Visualization Examples

1 / 4
Social Network Analysis Visualization with NetworkX and Plotly - Interactive Network Graphs - Community Detection - Centrality Measures - Path Analysis - Network Metrics - RSK World

Social Network Analysis Core Features | NetworkX Network Graph Features | Interactive Network Features

Interactive Network Graphs

  • 2D and 3D network graphs
  • Zoom and pan functionality
  • Hover tooltips with node data
  • Customizable node and edge styling
  • Multiple layout algorithms

Community Detection

  • Louvain algorithm
  • Color-coded communities
  • Community statistics
  • Subgraph extraction
  • Community size analysis

Centrality Measures (5 Types)

  • Degree, Betweenness, Closeness
  • Eigenvector and PageRank
  • Key node identification
  • Side-by-side comparison
  • Influential node analysis

Path Analysis

  • Shortest path finding
  • Path visualization
  • Average path length
  • Network diameter
  • Path statistics

Network Metrics Dashboard

  • Network density
  • Clustering coefficient
  • Degree distribution
  • Network size metrics
  • Visual gauge charts

Jupyter Notebook

  • network_analysis.ipynb
  • Interactive exploration
  • Step-by-step examples
  • All features demonstrated
  • Comprehensive tutorial

Advanced Network Analysis Features | Network Generation | Path Analysis | Network Comparison

Edge Analysis

  • Edge weights visualization
  • Edge betweenness calculation
  • Color-coded edge importance
  • Interactive edge hover info

Subgraph Extraction

  • Custom subgraph extraction
  • Community subgraph extraction
  • Subgraph visualization
  • Independent subgraph analysis

Data Export

  • CSV, JSON data export
  • PNG, PDF, SVG image export
  • Interactive HTML export
  • Edge list export

Network Generation

  • Random networks
  • Scale-free networks
  • Small-world networks
  • Complete, star, ring, grid
  • Community networks

Analysis Types | Network Analysis Types | Interactive Network Features

Analysis Type Description Use Case
Interactive Network Graphs 2D and 3D node-link diagrams with interactive zoom, pan, and hover Visualize network structures, relationships, and connections
Community Detection Louvain algorithm for automatic community detection with color-coded visualization Identify clusters and communities within networks
Centrality Measures (5 Types) Degree, Betweenness, Closeness, Eigenvector, and PageRank centralities Identify key nodes and influential network members
Network Metrics Dashboard Density, clustering coefficient, degree distribution, network size Understand overall network structure and properties
Path Analysis Shortest path finding, average path length, network diameter Analyze connectivity and distance between nodes
Edge Analysis Edge weights, edge betweenness, color-coded importance Understand edge importance and network connections
Subgraph Extraction Extract custom or community-based subgraphs Analyze specific network components independently
Network Generation Random, scale-free, small-world, complete, star, ring, grid networks Generate various network types for analysis and testing
Key Node Identification Find important nodes by various centrality measures Identify influential nodes, bridges, and hubs
Network Resilience Analysis Test network robustness by removing nodes (random or targeted) Evaluate network stability and vulnerability
Network Comparison Compare multiple networks side-by-side with metrics Analyze differences between network structures

Technologies Used | Python Technologies | Network Analysis Stack | Graph Analysis Tools

This Social Network Analysis Visualization project is built using modern Python network analysis and graph visualization technologies. The core implementation uses Python 3.8+ as the primary programming language, NetworkX 3.0+ for network analysis and graph operations, and Plotly 5.17.0+ for creating interactive network graphs. The project includes Pandas 2.0.0+ for data manipulation, NumPy 1.24.0+ for numerical computing, Jupyter 1.0.0+ for interactive development, scipy 1.10.0+ for scientific computing, matplotlib 3.7.0+ for plotting, python-louvain 0.16+ for community detection, and optional kaleido 0.2.1+ for image export. The visualization library features interactive 2D/3D network graphs with zoom and pan, community detection using Louvain algorithm, centrality measures (Degree, Betweenness, Closeness, Eigenvector, PageRank), network metrics dashboard, edge analysis, shortest path visualization, subgraph extraction, network generation (random, scale-free, small-world, complete, star, ring, grid), path analysis, key node identification, network resilience analysis, network comparison, and export functionality for network analysis, graph theory applications, and social network analysis.

The project uses NetworkX as the core network analysis library and Plotly as the visualization library for creating interactive network graphs with Python. It supports network visualization through interactive 2D/3D network graphs with customizable layouts, community detection (Louvain algorithm) with color-coded communities, centrality measures (Degree, Betweenness, Closeness, Eigenvector, PageRank) for identifying key nodes, network metrics dashboard with density, clustering coefficient, and degree distribution, edge analysis with edge weights and betweenness, shortest path visualization and path analysis, subgraph extraction for analyzing specific components, network generation functions for various network types, key node identification by various metrics, network resilience analysis to test robustness, network comparison side-by-side, and export functionality (CSV, JSON, PNG, PDF, SVG, HTML). The project includes network data loading from CSV files and network generation functions. The system includes interactive features such as zoom and pan, hover tooltips with node and edge data, customizable styling for nodes and edges, multiple layout algorithms (spring, circular, etc.), and HTML network export capabilities for network analysis, graph theory, social network analysis, and network visualization applications.

Python 3.8+ NetworkX 3.0+ Plotly 5.17.0+ Pandas 2.0.0+ NumPy 1.24.0+ Jupyter 1.0.0+ Community Detection Centrality Measures Path Analysis Network Generation scipy 1.10.0+

Installation & Usage Guide | How to Install Network Analysis | Setup Tutorial

Installation

Version: v1.0.0 (December 2024)

Install all required dependencies for the Social Network Analysis Visualization project:

# Install all requirements pip install -r requirements.txt # Required packages: # - networkx>=3.0 # - plotly>=5.17.0 # - pandas>=2.0.0 # - numpy>=1.24.0 # - jupyter>=1.0.0 # - scipy>=1.10.0 # - matplotlib>=3.7.0 # - python-louvain>=0.16 # Optional packages for advanced features: # - kaleido>=0.2.1 # For image export (PNG, PDF, SVG) # Verify installation python test_project.py

Running Jupyter Notebooks

Start Jupyter Notebook to explore the network analysis examples:

# Start Jupyter Notebook jupyter notebook # Or use JupyterLab jupyter lab # Open the notebook: # - network_analysis.ipynb - Main analysis notebook with all features # * Interactive network graphs (2D/3D) # * Community detection # * Centrality measures # * Network metrics dashboard # * Path analysis # * Network generation # * Subgraph extraction # * Network comparison # * Export functionality

Running Example Scripts

Run Python scripts to generate network visualizations:

# Run main analysis script: python network_analysis.py # This will: # - Create a sample network # - Perform network analysis # - Generate interactive HTML visualizations # - Save outputs to output/ directory # Run advanced analysis: python advanced_analysis.py # Example usage in Python: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer # Create and analyze network G = create_sample_network() analysis = analyze_network(G) # Visualize visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) fig.show()

Project Features

Explore the comprehensive network analysis features:

# Project Features (v1.0.0 - December 2024): # 1. Interactive Network Graphs - 2D and 3D node-link diagrams with Plotly # 2. Community Detection - Louvain algorithm with color-coded communities # 3. Centrality Measures (5 Types) - Degree, Betweenness, Closeness, Eigenvector, PageRank # 4. Network Metrics Dashboard - Density, clustering coefficient, degree distribution # 5. Edge Analysis - Edge weights and betweenness visualization # 6. Shortest Path Visualization - Find and visualize paths between nodes # 7. Subgraph Extraction - Extract and visualize subgraphs # 8. Network Generation (8 Types) - Random, scale-free, small-world, complete, star, ring, grid, community networks # 9. Path Analysis - Average path length, network diameter, path statistics # 10. Key Node Identification - Find important nodes by various metrics # 11. Network Resilience Analysis - Test network robustness by removing nodes # 12. Network Comparison - Compare multiple networks side-by-side # 13. Data Export - CSV, JSON, PNG, PDF, SVG, HTML export formats # 14. Data Loading - Load networks from CSV files # 15. 1 Jupyter Notebook - network_analysis.ipynb with all features # 16. 6 Python Modules - network_analysis, network_visualizer, network_generator, advanced_analysis, export_utils, utils # All features are demonstrated in the Jupyter notebook

Basic Usage Example

Create network visualizations with Python:

# Basic Usage Example: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer from advanced_analysis import analyze_shortest_paths, find_key_nodes # Create and analyze network G = create_sample_network() analysis = analyze_network(G) # Visualize network visualizer = NetworkVisualizer() fig1 = visualizer.create_network_graph(G, analysis) fig1.show() # Analyze shortest paths path_analysis = analyze_shortest_paths(G) # Find key nodes key_nodes = find_key_nodes(G, analysis) # Create advanced visualization with community detection fig2 = visualizer.create_community_graph(G, analysis) fig2.show()

Project Structure | Network Analysis File Structure | Source Code Organization

network-analysis/
├── README.md # Main documentation
├── FEATURES.md # Complete features list
├── RELEASE_NOTES.md # Release notes (v1.0.0 - Dec 2024)
├── PROJECT_SUMMARY.md # Project summary
├── QUICKSTART.md # Quick start guide
├── requirements.txt # Python dependencies
├── setup.py # Package setup script
├── .gitignore # Git ignore file
├── LICENSE # MIT License
│
├── network_analysis.ipynb # Main analysis notebook
│ # Interactive network graphs (2D/3D)
│ # Community detection, centrality measures
│ # Network metrics, path analysis
│
├── network_analysis.py # Main analysis script
├── network_visualizer.py # Visualization module
├── network_generator.py # Network generation utilities
├── advanced_analysis.py # Advanced analysis features
├── export_utils.py # Export functionality
├── utils.py # Utility functions
├── __init__.py # Package initialization
├── test_project.py # Project verification script
├── index.html # HTML demo page
│
├── data/ # Data directory
│ └── sample_network.csv # Sample network data
│
└── output/ # Output directory (auto-created) └── (generated visualizations and exports)

Configuration Options | NetworkX Configuration | Network Analysis Customization Guide

NetworkX and Plotly Configuration

Version: v1.0.0 (December 2024)

Customize network visualization settings in Python code:

# NetworkX and Plotly Configuration for Network Analysis import networkx as nx import plotly.graph_objects as go from network_visualizer import NetworkVisualizer # Default configuration in network_visualizer.py: # - layout: 'spring' (can be 'spring', 'circular', 'kamada_kawai', 'spectral', etc.) # - node_size: Based on degree centrality # - node_color: Based on community or centrality # - edge_width: Based on edge weight # - height: 800 (figure height in pixels) # - width: 1200 (figure width in pixels) # Customize in function calls: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer G = create_sample_network() analysis = analyze_network(G) visualizer = NetworkVisualizer() fig = visualizer.create_network_graph( G, analysis, layout='spring', # Change layout algorithm node_size_factor=10, # Adjust node sizes height=1000, # Adjust height width=1400 # Adjust width ) # Available layout algorithms: # - 'spring' (default): Force-directed layout # - 'circular': Circular arrangement # - 'kamada_kawai': Kamada-Kawai layout # - 'spectral': Spectral layout # - 'random': Random positions

Configuration Tips:

  • LAYOUT: Choose from 'spring', 'circular', 'kamada_kawai', 'spectral', 'random', etc. Default: 'spring'
  • NODE_SIZE: Based on degree centrality by default. Can be customized by other centrality measures or fixed size
  • NODE_COLOR: Based on community detection or centrality measures. Customize color schemes
  • EDGE_WIDTH: Based on edge weight. Adjust for better visibility
  • DIMENSIONS: Set figure height and width in pixels. Default: 800x1200
  • EXPORT_FORMAT: HTML (interactive), PNG, PDF, SVG (requires kaleido 0.2.1+ package), CSV, JSON

Network Data Format Requirements

Works with network data from CSV files or NetworkX graphs. Required structure:

# Supported data formats: # - NetworkX Graph objects (Graph, DiGraph, MultiGraph) # - CSV files with edge list (source, target, weight columns) # Required CSV structure: from utils import load_network_from_csv # Load network from CSV (automatically returns NetworkX Graph): G = load_network_from_csv('data/sample_network.csv') # Required CSV columns: # - source (node identifier) # - target (node identifier) # - weight (optional, numeric) # Example CSV structure: # source,target,weight # A,B,1.0 # B,C,2.0 # C,D,1.5 # A,C,0.8 # Works with: # - Any network data in edge list format # - Weighted or unweighted networks # - Directed or undirected networks # - NetworkX Graph objects created programmatically

Customizing Network Appearance

Modify network visualization configurations in network_visualizer.py:

# Network customization in Python: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer import plotly.graph_objects as go # Create and analyze network G = create_sample_network() analysis = analyze_network(G) # Create network graph visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) # Customize layout: fig.update_layout( title={ 'text': 'Custom Network Graph', 'x': 0.5, 'font': {'size': 24, 'color': '#1e293b'} }, height=1000, # Adjust height width=1400, # Adjust width margin=dict(l=50, r=50, t=80, b=50), showlegend=True ) # Customize node appearance: # Node sizes based on degree centrality # Node colors based on community detection # Edge widths based on edge weights # Save customized network fig.write_html('custom_network.html')

Adding Custom Network Visualizations

Add new network visualizations using NetworkX and Plotly:

# Add new visualization function to network_visualizer.py: import networkx as nx import plotly.graph_objects as go import numpy as np def create_custom_network_graph(G, title='Custom Network', **kwargs): """Create a custom network graph visualization.""" # Calculate layout pos = nx.spring_layout(G, k=1, iterations=50) # Extract node and edge positions edge_x = [] edge_y = [] for edge in G.edges(): x0, y0 = pos[edge[0]] x1, y1 = pos[edge[1]] edge_x.extend([x0, x1, None]) edge_y.extend([y0, y1, None]) node_x = [pos[node][0] for node in G.nodes()] node_y = [pos[node][1] for node in G.nodes()] # Create edge trace edge_trace = go.Scatter( x=edge_x, y=edge_y, line=dict(width=0.5, color='#888'), hoverinfo='none', mode='lines' ) # Create node trace node_trace = go.Scatter( x=node_x, y=node_y, mode='markers', hoverinfo='text', marker=dict(size=10, color='lightblue') ) # Create figure fig = go.Figure(data=[edge_trace, node_trace], layout=go.Layout( title=title, showlegend=False, hovermode='closest', height=kwargs.get('height', 800), width=kwargs.get('width', 1200) )) # Save if output file provided if kwargs.get('output_file'): fig.write_html(kwargs['output_file']) print(f"Network graph saved as '{kwargs['output_file']}'") return fig # Use in your code: from network_analysis import create_sample_network from network_visualizer import create_custom_network_graph G = create_sample_network() fig = create_custom_network_graph(G, title='My Custom Network Graph', output_file='custom_network.html')

Project Architecture | Network Analysis Architecture | System Architecture | Technical Architecture

Network Analysis Architecture

1. NetworkX and Plotly Visualization Framework:

  • Built on NetworkX for network analysis and graph operations
  • Uses Plotly Graph Objects for interactive network visualization
  • 2D and 3D network graphs with node-link diagrams
  • Interactive HTML output with zoom, pan, and hover
  • Multiple layout algorithms for different network types

2. Data Processing Pipeline:

  • CSV file loading for network data (edge lists)
  • NetworkX Graph objects for network representation
  • Network generation functions for various network types
  • Data validation and network structure validation
  • Centrality measure calculations

3. Analysis Components:

  • Network graphs for relationship visualization
  • Community detection (Louvain algorithm)
  • Centrality measures (Degree, Betweenness, Closeness, Eigenvector, PageRank)
  • Path analysis and shortest path finding
  • Network metrics dashboard with comprehensive statistics

Module Structure

The project is organized into focused modules:

# Module Structure: # network_visualizer.py - Network visualization functions from network_visualizer import ( NetworkVisualizer, # Main visualization class create_network_graph, # Create 2D network graph create_3d_network_graph, # Create 3D network graph create_community_graph, # Create community detection graph create_centrality_graph # Create centrality comparison graph ) # network_analysis.py - Main network analysis functions from network_analysis import ( create_sample_network, # Create sample network analyze_network, # Analyze network metrics calculate_centrality_measures # Calculate all centrality measures ) # advanced_analysis.py - Advanced analysis features from advanced_analysis import ( analyze_shortest_paths, # Analyze shortest paths find_key_nodes, # Find key nodes by metrics analyze_network_resilience, # Test network resilience compare_networks # Compare multiple networks ) # network_generator.py - Network generation utilities from network_generator import ( NetworkGenerator, # Network generator class generate_random_network, # Generate random network generate_scale_free_network, # Generate scale-free network generate_small_world_network # Generate small-world network ) # utils.py - Utility functions from utils import ( load_network_from_csv, # Load network from CSV save_network_to_csv, # Save network to CSV validate_network # Validate network structure ) # export_utils.py - Export functionality from export_utils import ( NetworkExporter, # Network exporter class export_analysis_to_csv, # Export analysis to CSV export_visualization, # Export visualization (PNG/PDF/SVG) export_network_json # Export network to JSON )

Data Format and Processing

How network data is processed for analysis:

# Data Format Requirements: # Edge list format from CSV (source, target, weight) # Example data structure: # source,target,weight # A,B,1.0 # B,C,2.0 # C,D,1.5 # A,C,0.8 # Data Processing Flow: from utils import load_network_from_csv from network_analysis import analyze_network from network_visualizer import NetworkVisualizer # Load network from CSV G = load_network_from_csv('data/sample_network.csv') # Automatically returns NetworkX Graph object # Analyze network analysis = analyze_network(G) # Create visualization visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) fig.write_html('network_graph.html')

Analysis Types and Usage

Different network analysis types and their use cases:

  • Network Graphs: Interactive 2D/3D node-link diagrams using go.Scatter() and NetworkX layouts
  • Community Detection: Louvain algorithm using community.best_partition() from python-louvain
  • Centrality Measures: Degree, Betweenness, Closeness, Eigenvector, PageRank using NetworkX functions
  • Path Analysis: Shortest path finding using nx.shortest_path() and path statistics
  • Network Metrics: Density, clustering, degree distribution using NetworkX metrics functions
  • Subgraph Extraction: Extract subgraphs using G.subgraph() for component analysis
  • Network Generation: Generate networks using NetworkX generators (random, scale-free, small-world)
  • Key Node Identification: Find important nodes using centrality rankings and threshold analysis
  • Network Resilience: Test robustness using node removal and component analysis
  • Network Comparison: Compare networks using metrics comparison and statistical analysis

Advanced Features Usage | Network Analysis Usage Guide | How to Use Network Analysis

Using Basic Network Functions

How to create different types of network visualizations:

# Basic Network Usage Examples: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer from utils import load_network_from_csv # Create or load network G = create_sample_network() # Or load from CSV: G = load_network_from_csv('data/sample_network.csv') # Analyze network analysis = analyze_network(G) # 1. Create Basic 2D Network Graph: visualizer = NetworkVisualizer() fig1 = visualizer.create_network_graph(G, analysis, title='Network Graph') fig1.show() # 2. Create 3D Network Graph: fig2 = visualizer.create_3d_network_graph(G, analysis, title='3D Network Graph') fig2.show() # 3. Create Community Detection Graph: fig3 = visualizer.create_community_graph(G, analysis, title='Community Detection') fig3.show() # 4. Create Centrality Comparison Graph: fig4 = visualizer.create_centrality_graph(G, analysis, title='Centrality Measures') fig4.show() # 5. Create Network Metrics Dashboard: fig5 = visualizer.create_metrics_dashboard(G, analysis, title='Network Metrics') fig5.show()

Using Advanced Features

Create advanced network analysis visualizations:

# Advanced Features Usage: from network_analysis import create_sample_network, analyze_network from advanced_analysis import analyze_shortest_paths, find_key_nodes, analyze_network_resilience, compare_networks from network_generator import NetworkGenerator from network_visualizer import NetworkVisualizer # Create network G = create_sample_network() analysis = analyze_network(G) # 1. Path Analysis: path_analysis = analyze_shortest_paths(G) print(f"Average Path Length: {path_analysis['avg_path_length']}") print(f"Network Diameter: {path_analysis['diameter']}") # 2. Key Node Identification: key_nodes = find_key_nodes(G, analysis) print(f"Top Nodes by Degree: {key_nodes['top_degree']}") print(f"Top Nodes by Betweenness: {key_nodes['top_betweenness']}") # 3. Network Resilience Analysis: resilience = analyze_network_resilience(G, removal_type='random', num_removals=10) print(f"Resilience Metrics: {resilience}") # 4. Network Generation: generator = NetworkGenerator() random_net = generator.generate_random_network(50, 0.1) scale_free = generator.generate_scale_free_network(50, 2) small_world = generator.generate_small_world_network(50, 4, 0.1) # 5. Network Comparison: networks = [G, random_net, scale_free] comparison = compare_networks(networks, labels=['Original', 'Random', 'Scale-Free']) print(comparison) # 6. Subgraph Extraction: from advanced_analysis import extract_community_subgraphs subgraphs = extract_community_subgraphs(G, analysis) for i, subgraph in enumerate(subgraphs): print(f"Community {i}: {len(subgraph.nodes())} nodes")

Understanding Analysis Types

When to use different analysis types for network data:

# Analysis Type Usage Guide: # 1. Network Graphs (2D/3D) # - Use: Visualize network structures and relationships # - Shows: Node-link diagrams with nodes and edges # - Best for: Understanding network topology, identifying clusters # - Example: Social networks, organizational structures, relationship mapping # 2. Community Detection # - Use: Identify clusters and communities within networks # - Shows: Color-coded communities using Louvain algorithm # - Best for: Finding groups, understanding network structure # - Example: Social groups, functional modules, network clusters # 3. Centrality Measures # - Use: Identify important nodes in the network # - Shows: Degree, Betweenness, Closeness, Eigenvector, PageRank # - Best for: Finding key nodes, influential members, bridges # - Example: Key influencers, critical nodes, hub identification # 4. Path Analysis # - Use: Analyze connectivity and distances between nodes # - Shows: Shortest paths, average path length, network diameter # - Best for: Understanding network connectivity, information flow # - Example: Communication paths, shortest routes, network efficiency # 5. Network Metrics Dashboard # - Use: Understand overall network properties # - Shows: Density, clustering coefficient, degree distribution # - Best for: Network characterization, comparison, statistics # - Example: Network density analysis, clustering analysis, degree distribution # 6. Edge Analysis # - Use: Understand edge importance and connections # - Shows: Edge weights, edge betweenness, critical edges # - Best for: Identifying important connections, edge removal impact # - Example: Critical connections, edge importance, network flow # 7. Subgraph Extraction # - Use: Analyze specific network components # - Shows: Extracted subgraphs from communities or custom selections # - Best for: Component analysis, focused investigation # - Example: Community subgraphs, component analysis, focused studies # 8. Network Generation # - Use: Generate networks for testing and comparison # - Shows: Random, scale-free, small-world, and other network types # - Best for: Testing algorithms, comparison, simulation # - Example: Random networks, scale-free networks, small-world networks # 9. Key Node Identification # - Use: Find most important nodes by various metrics # - Shows: Top nodes by centrality, influential nodes, bridges # - Best for: Identifying key players, critical nodes, hubs # - Example: Key influencers, critical infrastructure, hub nodes # 10. Network Resilience Analysis # - Use: Test network robustness and vulnerability # - Shows: Resilience metrics after node removal (random or targeted) # - Best for: Network stability, vulnerability assessment # - Example: Random failures, targeted attacks, network robustness

Data Preparation and Customization

Prepare and customize your network data for analysis:

# Data Preparation Examples: from utils import load_network_from_csv, save_network_to_csv from network_analysis import create_sample_network, analyze_network from network_generator import NetworkGenerator import networkx as nx # 1. Load Network from CSV: G = load_network_from_csv('data/sample_network.csv') # Automatically returns NetworkX Graph object # 2. Create Network Programmatically: G = nx.Graph() G.add_edge('A', 'B', weight=1.0) G.add_edge('B', 'C', weight=2.0) G.add_edge('C', 'D', weight=1.5) # 3. Generate Network: generator = NetworkGenerator() G = generator.generate_random_network(50, 0.1) # Or: G = generator.generate_scale_free_network(50, 2) # 4. Add Node Attributes: for node in G.nodes(): G.nodes[node]['label'] = f'Node_{node}' G.nodes[node]['category'] = 'default' # 5. Add Edge Attributes: for edge in G.edges(): G.edges[edge]['weight'] = 1.0 G.edges[edge]['type'] = 'default' # 6. Filter Network (remove low-degree nodes): G_filtered = G.copy() nodes_to_remove = [n for n in G_filtered.nodes() if G_filtered.degree(n) < 2] G_filtered.remove_nodes_from(nodes_to_remove) # 7. Extract Largest Component: largest_component = max(nx.connected_components(G), key=len) G_largest = G.subgraph(largest_component).copy() # 8. Analyze Network: analysis = analyze_network(G) # Returns dictionary with all network metrics

Exporting Networks

Export networks and visualizations to different formats:

# Export Network Examples: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer from export_utils import NetworkExporter from utils import save_network_to_csv # Create and analyze network G = create_sample_network() analysis = analyze_network(G) # Create visualization visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) # 1. Export as HTML (interactive, default): fig.write_html('network_graph.html') # Opens in browser with full interactivity # 2. Export as PNG (requires kaleido): # Install: pip install kaleido fig.write_image('network_graph.png', width=1920, height=1080) # 3. Export as PDF (requires kaleido): fig.write_image('network_graph.pdf') # 4. Export as SVG: fig.write_image('network_graph.svg') # 5. Export Network Data as CSV: save_network_to_csv(G, filename='network_data.csv') # 6. Export Analysis Results as CSV: exporter = NetworkExporter() exporter.export_analysis_to_csv(analysis, filename='analysis_results.csv') # 7. Export Network as JSON: exporter.export_network_json(G, filename='network_data.json')

Complete Network Analysis Workflow | Step-by-Step Guide | Network Tutorial

Step-by-Step Network Analysis Setup

Step 1: Install Dependencies

# Install all required packages pip install -r requirements.txt # Required packages: # - networkx>=3.0 # - plotly>=5.17.0 # - pandas>=2.0.0 # - numpy>=1.24.0 # - jupyter>=1.0.0 # - scipy>=1.10.0 # - matplotlib>=3.7.0 # - python-louvain>=0.16 # Optional packages for advanced features: # - kaleido>=0.2.1 # For image export (PNG, PDF, SVG) # Verify installation python test_project.py

Step 2: Prepare Network Data

# Option 1: Load network from CSV file from utils import load_network_from_csv # Load network data (edge list format) G = load_network_from_csv('data/sample_network.csv') # Automatically returns NetworkX Graph object # Option 2: Create network programmatically from network_analysis import create_sample_network G = create_sample_network() # Option 3: Generate network from network_generator import NetworkGenerator generator = NetworkGenerator() G = generator.generate_random_network(50, 0.1) # Or: G = generator.generate_scale_free_network(50, 2) # Data format (CSV): # source,target,weight # A,B,1.0 # B,C,2.0 # C,D,1.5

Step 3: Create Basic Network Visualizations

# Run main analysis script: python network_analysis.py # This will: # - Create a sample network # - Perform network analysis # - Generate interactive HTML visualizations # - Save outputs to output/ directory # Or create visualizations programmatically: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer G = create_sample_network() analysis = analyze_network(G) visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) fig.show() # Export visualization: fig.write_html('network_graph.html') # Open HTML file in browser to view interactive network

Step 4: Explore Jupyter Notebook

  • Open network_analysis.ipynb for comprehensive tutorial
  • Run cells step-by-step to learn each analysis type
  • Explore interactive network graphs, community detection, centrality measures
  • Modify code examples to use different networks
  • Export visualizations as HTML, PNG, PDF, SVG, CSV, or JSON

Step 5: Customize Network Visualizations

# Customize network visualizations in Python code: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer G = create_sample_network() analysis = analyze_network(G) visualizer = NetworkVisualizer() # Change layout algorithm fig = visualizer.create_network_graph(G, analysis, layout='spring') # Available layouts: 'spring', 'circular', 'kamada_kawai', 'spectral', 'random' # Adjust node sizes fig = visualizer.create_network_graph(G, analysis, node_size_factor=15) # Adjust colors fig = visualizer.create_network_graph(G, analysis, color_by='community') # Options: 'community', 'degree', 'betweenness', 'closeness', 'eigenvector', 'pagerank' # Show/hide features fig = visualizer.create_network_graph(G, analysis, show_labels=True, show_weights=True) # Modify network_visualizer.py for advanced configurations

Network Analysis Customization Examples | Customization Guide | Code Examples

Customizing Network Layouts

Change layout algorithms and styling for network graphs:

# Customize Network Layouts: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer G = create_sample_network() analysis = analyze_network(G) visualizer = NetworkVisualizer() # Available layouts: # 'spring' (default), 'circular', 'kamada_kawai', 'spectral', 'random', etc. # Example 1: Use spring layout (default, force-directed) fig = visualizer.create_network_graph(G, analysis, layout='spring') fig.show() # Example 2: Use circular layout fig = visualizer.create_network_graph(G, analysis, layout='circular') fig.show() # Example 3: Use Kamada-Kawai layout fig = visualizer.create_network_graph(G, analysis, layout='kamada_kawai') fig.show() # Example 4: Use spectral layout fig = visualizer.create_network_graph(G, analysis, layout='spectral') fig.show() # Note: Spring layout is default for most network types

Adjusting Node and Edge Styling

Control node sizes, colors, and edge widths:

# Adjust Node and Edge Styling: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer G = create_sample_network() analysis = analyze_network(G) visualizer = NetworkVisualizer() # Node size options: # - Based on degree centrality (default) # - Based on other centrality measures # - Fixed size # Example 1: Node size by degree (default) fig = visualizer.create_network_graph(G, analysis, node_size_by='degree') fig.show() # Example 2: Node size by betweenness centrality fig = visualizer.create_network_graph(G, analysis, node_size_by='betweenness') fig.show() # Example 3: Fixed node size fig = visualizer.create_network_graph(G, analysis, node_size_factor=20) fig.show() # Node color options: # - By community (default) # - By centrality measures # - Custom colors # Example 4: Color by community fig = visualizer.create_network_graph(G, analysis, color_by='community') fig.show() # Example 5: Color by PageRank fig = visualizer.create_network_graph(G, analysis, color_by='pagerank') fig.show() # Edge width based on weight (if available) # Adjust edge_width_factor for better visibility

Changing Network Generation Parameters

Generate different types of networks with custom parameters:

# Generate Different Network Types: from network_generator import NetworkGenerator generator = NetworkGenerator() # Available network types: # 'random' - Erdos-Renyi random graph # 'scale_free' - Barabasi-Albert scale-free network # 'small_world' - Watts-Strogatz small-world network # 'complete' - Complete graph # 'star' - Star network # 'ring' - Ring network # 'grid' - Grid network # 'community' - Community network # Example 1: Random Network G1 = generator.generate_random_network(n=50, p=0.1) print(f"Random Network: {len(G1.nodes())} nodes, {len(G1.edges())} edges") # Example 2: Scale-Free Network G2 = generator.generate_scale_free_network(n=50, m=2) print(f"Scale-Free Network: {len(G2.nodes())} nodes, {len(G2.edges())} edges") # Example 3: Small-World Network G3 = generator.generate_small_world_network(n=50, k=4, p=0.1) print(f"Small-World Network: {len(G3.nodes())} nodes, {len(G3.edges())} edges") # Example 4: Complete Network G4 = generator.generate_complete_network(n=20) print(f"Complete Network: {len(G4.nodes())} nodes, {len(G4.edges())} edges") # Tip: Random networks for testing, scale-free for real-world modeling

Modifying Data Source

Load network data from different sources:

# Load Network Data from Different Sources: from utils import load_network_from_csv from network_visualizer import NetworkVisualizer import networkx as nx import pandas as pd # Option 1: Load from CSV file (edge list format, recommended) G = load_network_from_csv('data/sample_network.csv') # Required columns: source, target, weight (optional) # Option 2: Create network programmatically G = nx.Graph() G.add_edge('A', 'B', weight=1.0) G.add_edge('B', 'C', weight=2.0) # Option 3: Generate network from network_generator import NetworkGenerator generator = NetworkGenerator() G = generator.generate_random_network(50, 0.1) # Option 4: Load from edge list DataFrame df = pd.read_csv('edges.csv') G = nx.from_pandas_edgelist(df, 'source', 'target', 'weight', create_using=nx.Graph) # Option 5: Load from adjacency matrix adj_matrix = pd.read_csv('adjacency.csv', index_col=0) G = nx.from_pandas_adjacency(adj_matrix) # Option 6: Load from JSON import json with open('network.json', 'r') as f: data = json.load(f) G = nx.node_link_graph(data) # Then create visualization visualizer = NetworkVisualizer() analysis = analyze_network(G) fig = visualizer.create_network_graph(G, analysis) fig.write_html('network_graph.html')

Customizing Network Layout

Modify network appearance and layout settings:

# Customize Network Layout: from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer import plotly.graph_objects as go # Create and analyze network G = create_sample_network() analysis = analyze_network(G) # Create visualization visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) # Customize layout fig.update_layout( title={ 'text': 'Custom Network Graph', 'x': 0.5, 'font': {'size': 24, 'color': '#1e293b'} }, height=1000, # Adjust height (default: 800) width=1400, # Adjust width (default: 1200) margin=dict(l=50, r=50, t=80, b=50), showlegend=True ) # Update axes (for 2D graphs) fig.update_xaxes( title_text="X Position", title_font=dict(size=16) ) fig.update_yaxes( title_text="Y Position", title_font=dict(size=16) ) # Save customized network fig.write_html('custom_network.html')

Network Data Information | Data Format | Edge List Format | Data Requirements

Data Format Requirements

The project works with edge list format for network data:

  • Required columns: source, target (weight is optional)
  • Node identifiers: Can be strings, integers, or any hashable type
  • Edge weights: Numeric values (optional, defaults to 1.0)
  • Automatic NetworkX Graph object creation
  • Support for directed and undirected networks
  • Automatic network validation and structure checking

Sample Data Format

Your network data CSV file should follow this structure:

# CSV file structure (network_data.csv): source,target,weight A,B,1.0 B,C,2.0 C,D,1.5 A,C,0.8 B,D,1.2 C,E,2.5 # Column descriptions: # - source: Source node identifier (string or integer) # - target: Target node identifier (string or integer) # - weight: Edge weight (numeric, optional, defaults to 1.0) # For unweighted networks, weight column can be omitted: # source,target # A,B # B,C # C,D # For multiple networks, use separate files or create multiple Graph objects

Loading Network Data

Load network data from CSV files or create programmatically:

# Load network data from CSV from utils import load_network_from_csv # Load single network: G = load_network_from_csv('data/sample_network.csv') # Or create programmatically: from network_analysis import create_sample_network G = create_sample_network() # Or generate network: from network_generator import NetworkGenerator generator = NetworkGenerator() G = generator.generate_random_network(50, 0.1) # Network types available: # - Random networks (Erdos-Renyi) # - Scale-free networks (Barabasi-Albert) # - Small-world networks (Watts-Strogatz) # - Complete, star, ring, grid networks # - Community networks # Save network data: from utils import save_network_to_csv save_network_to_csv(G, 'my_network.csv')

Using Your Own Network Data

Use your own network data for analysis:

# Steps to use your own network data: # 1. Prepare your CSV file # - Required: source, target columns (weight is optional) # - Source/Target: Node identifiers (strings or integers) # - Weight: Numeric values for edge weights (optional) # 2. Load and validate data from utils import load_network_from_csv, validate_network G = load_network_from_csv('your_network_data.csv') # Automatically converts to NetworkX Graph object # Validate network from utils import validate_network G = validate_network(G) # Checks for valid graph structure, nodes, and edges # 3. Create visualization from network_visualizer import NetworkVisualizer from network_analysis import analyze_network analysis = analyze_network(G) visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) fig.write_html('network_graph.html') # 4. Verify data format # - Check source and target columns exist # - Ensure nodes are valid identifiers # - Verify edge weights are numeric (if provided) # - Check for proper graph structure # - Ensure no duplicate edges (unless MultiGraph) # 5. Use with all analysis types # - All analysis types work with your network # - Community detection works automatically # - Centrality measures work with any network # - Path analysis and network metrics work with validated networks

Troubleshooting & Best Practices | Common Issues | Performance Optimization | Best Practices

Common Issues

  • Network Not Loading: Ensure CSV file has correct format (source, target, weight columns). Check file path is correct
  • Network Data Not Found: Verify CSV file exists and has proper edge list format. Check column names match (source, target)
  • Import Errors: Verify all dependencies installed: pip install -r requirements.txt. Check Python version (3.8+)
  • Network Format Errors: Ensure source and target columns exist. Verify nodes are valid identifiers (strings or integers)
  • Graph Not Rendering: Check browser console for JavaScript errors. Verify Plotly is loaded correctly. Check network size (very large networks may be slow)
  • Slow Performance: Reduce network size, filter low-degree nodes, or extract largest component for large networks
  • Memory Issues: Reduce number of nodes/edges, use network filtering, or process in smaller subgraphs
  • Export Not Working: Ensure kaleido is installed for image export: pip install kaleido
  • NetworkX Errors: Check NetworkX version (3.0+). Verify graph structure is valid. Ensure nodes and edges are properly formatted
  • Centrality Calculation Errors: Ensure network is connected (or use largest component). Some metrics require connected graphs
  • Community Detection Not Working: Verify python-louvain is installed. Check network has sufficient edges for community detection
  • Path Analysis Errors: Ensure network is connected. Path analysis requires connected components. Use largest component if needed
  • HTML Files Not Opening: Open HTML files in modern browser (Chrome, Firefox, Edge). Check file path is correct
  • Layout Issues: Try different layout algorithms ('spring', 'circular', 'kamada_kawai'). Some layouts work better for specific network types

Performance Optimization Tips

  • Network Size: Reduce network size or filter low-degree nodes to improve performance
  • Visualization Type: Use simpler layouts for large networks (circular layout is faster than spring layout for large networks)
  • Layout Algorithm: Choose appropriate layout based on network size (spring for small, circular/spectral for large networks)
  • Caching: Cache analysis results to avoid repeated calculations
  • Network Preprocessing: Pre-process and validate network before creating visualizations
  • Network Validation: Validate network structure early to avoid processing errors
  • HTML File Size: Large HTML files may load slowly. Consider exporting as images for sharing or filtering network
  • Browser Performance: Use modern browsers for best performance. Clear cache if issues occur

Best Practices

  • Network Quality: Ensure network data is clean, nodes are valid identifiers, and edges are properly formatted
  • Network Format: Always validate network format and convert to NetworkX Graph for proper analysis
  • Edge List Columns: Ensure source and target columns exist. Validate edge weights are numeric (if provided)
  • Network Size: For large networks (10K+ nodes), consider filtering or extracting largest component
  • Layout Algorithms: Choose appropriate layout algorithms for your network type (spring for small, circular for large)
  • Error Handling: Add error handling in network functions to prevent crashes
  • Network Validation: Always validate network structure and types before processing
  • Export Formats: Use HTML for interactive sharing, PNG/PDF/SVG for reports and presentations
  • Analysis Types: Choose appropriate analysis types (community detection for clusters, centrality for key nodes)
  • Documentation: Document custom modifications and network sources
  • Testing: Test with different network types and sizes
  • Sharing: HTML files are standalone and portable. Share via email, cloud storage, or web hosting

Use Cases and Applications

  • Social Network Analysis: Analyze social networks, relationships, and connections using network graphs
  • Community Detection: Identify communities and clusters within networks using Louvain algorithm
  • Key Node Identification: Find important nodes using centrality measures (Degree, Betweenness, PageRank)
  • Path Analysis: Analyze shortest paths, connectivity, and information flow in networks
  • Network Comparison: Compare multiple networks side-by-side with metrics and statistics
  • Network Resilience: Test network robustness and vulnerability by removing nodes
  • Network Generation: Generate various network types for testing and simulation
  • Subgraph Analysis: Extract and analyze specific network components independently
  • Network Reporting: Generate comprehensive network analysis reports with visualizations and statistics
  • Educational Purposes: Learn network analysis, graph theory, and social network concepts

Performance Benchmarks

Expected performance for different network sizes:

Network Size Nodes Load Time Graph Render Memory Usage
Small 10 - 100 < 1 second < 1 second < 50 MB
Medium 100 - 1K 1-2 seconds 1-3 seconds 50-150 MB
Large 1K - 10K 2-5 seconds 3-8 seconds 150-400 MB
Very Large 10K+ 5-15 seconds 8-20 seconds 400+ MB

Note: Performance depends on hardware, network complexity, and analysis type. Basic graphs are faster than complex community detection. Consider network filtering for very large networks.

System Requirements

Recommended system requirements for optimal performance:

Component Minimum Recommended Optimal
Python 3.8 3.9+ 3.10+
RAM 4 GB 8 GB 16 GB+
CPU 2 cores 4 cores 8+ cores
Storage 100 MB 500 MB 1 GB+
Browser Chrome 90+ Chrome 100+ Latest

Note: Network graphs run in browser. No GPU required. Performance scales with network size. HTML files are interactive and can be shared easily.

Real-World Examples & Use Cases | Network Analysis Use Cases | Social Network Analysis Examples

Example 1: Basic Network Analysis

Analyze network structures with interactive graphs and community detection:

# 1. Create or load network from network_analysis import create_sample_network, analyze_network from utils import load_network_from_csv G = create_sample_network() # Or: G = load_network_from_csv('data/sample_network.csv') # 2. Create basic network graph from network_visualizer import NetworkVisualizer analysis = analyze_network(G) visualizer = NetworkVisualizer() fig1 = visualizer.create_network_graph(G, analysis, title='Network Graph') fig1.show() # 3. Add community detection fig2 = visualizer.create_community_graph(G, analysis, title='Community Detection') fig2.show() # 4. Analyze centrality measures fig3 = visualizer.create_centrality_graph(G, analysis, title='Centrality Measures') fig3.show() # 5. Analyze network structure # - Identify communities and clusters # - Find key nodes by centrality # - Analyze network metrics # - Evaluate network connectivity

Example 2: Path Analysis and Key Node Identification

Analyze shortest paths and identify important nodes:

# Use Case: Path analysis and key node identification # 1. Create and analyze network from network_analysis import create_sample_network, analyze_network from advanced_analysis import analyze_shortest_paths, find_key_nodes G = create_sample_network() analysis = analyze_network(G) # 2. Analyze shortest paths path_analysis = analyze_shortest_paths(G) print(f"Average Path Length: {path_analysis['avg_path_length']:.2f}") print(f"Network Diameter: {path_analysis['diameter']}") # 3. Find key nodes key_nodes = find_key_nodes(G, analysis) print(f"Top Nodes by Degree: {key_nodes['top_degree']}") print(f"Top Nodes by Betweenness: {key_nodes['top_betweenness']}") # 4. Visualize shortest path between two nodes from network_visualizer import NetworkVisualizer visualizer = NetworkVisualizer() fig = visualizer.visualize_shortest_path(G, 'A', 'Z') fig.show() # 5. Analyze results # - Identify critical nodes # - Evaluate network connectivity # - Find shortest routes # - Understand information flow

Example 3: Network Comparison

Compare multiple networks side-by-side:

# Use Case: Network comparison # 1. Generate multiple networks from network_generator import NetworkGenerator generator = NetworkGenerator() random_net = generator.generate_random_network(50, 0.1) scale_free = generator.generate_scale_free_network(50, 2) small_world = generator.generate_small_world_network(50, 4, 0.1) # 2. Compare networks from advanced_analysis import compare_networks networks = [random_net, scale_free, small_world] comparison = compare_networks(networks, labels=['Random', 'Scale-Free', 'Small-World']) print(comparison) # 3. Analyze network metrics from network_analysis import analyze_network for i, G in enumerate(networks): analysis = analyze_network(G) print(f"Network {i}: Density={analysis['density']:.3f}, Clustering={analysis['clustering']:.3f}") # 4. Visualize comparison from network_visualizer import NetworkVisualizer visualizer = NetworkVisualizer() fig = visualizer.compare_networks(networks, labels=['Random', 'Scale-Free', 'Small-World']) fig.show() # 5. Analyze differences # - Compare network structures # - Evaluate metrics differences # - Understand network properties # - Identify best network type for use case

Example 4: Network Resilience Analysis

Test network robustness and vulnerability:

# Use Case: Network resilience analysis # 1. Create and analyze network from network_analysis import create_sample_network, analyze_network from advanced_analysis import analyze_network_resilience G = create_sample_network() analysis = analyze_network(G) # 2. Test random node removal resilience_random = analyze_network_resilience(G, removal_type='random', num_removals=10) print(f"Random Removal: Fragmentation={resilience_random['fragmentation']:.2%}") # 3. Test targeted node removal (high degree nodes) resilience_targeted = analyze_network_resilience(G, removal_type='targeted', num_removals=10) print(f"Targeted Removal: Fragmentation={resilience_targeted['fragmentation']:.2%}") # 4. Visualize resilience from network_visualizer import NetworkVisualizer visualizer = NetworkVisualizer() fig = visualizer.visualize_resilience(G, resilience_random) fig.show() # 5. Use cases: # - Network vulnerability assessment # - Critical infrastructure analysis # - Network stability testing # - Risk management

Example 5: Comprehensive Network Analysis

Comprehensive network analysis with all features:

# Use Case: Comprehensive network analysis # 1. Create and analyze network from network_analysis import create_sample_network, analyze_network G = create_sample_network() analysis = analyze_network(G) # 2. Community detection from advanced_analysis import extract_community_subgraphs subgraphs = extract_community_subgraphs(G, analysis) print(f"Number of communities: {len(subgraphs)}") # 3. Centrality analysis from advanced_analysis import find_key_nodes key_nodes = find_key_nodes(G, analysis) print(f"Top nodes by PageRank: {key_nodes['top_pagerank']}") # 4. Path analysis from advanced_analysis import analyze_shortest_paths path_analysis = analyze_shortest_paths(G) print(f"Average path length: {path_analysis['avg_path_length']:.2f}") # 5. Network metrics print(f"Density: {analysis['density']:.3f}") print(f"Clustering: {analysis['clustering']:.3f}") print(f"Nodes: {analysis['num_nodes']}, Edges: {analysis['num_edges']}") # 6. Create comprehensive visualization from network_visualizer import NetworkVisualizer visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis, show_communities=True, show_centrality=True, show_labels=True) fig.show() # 7. Use cases: # - Comprehensive network analysis # - Community structure identification # - Key node identification # - Network structure assessment

Integration Examples | Database Integration | API Integration | Web Integration

Integration with Database

Load network data from SQL database:

# Load network data from SQL database import sqlite3 import pandas as pd import networkx as nx from network_visualizer import NetworkVisualizer from network_analysis import analyze_network def load_network_from_db(network_id='network1'): """Load network data from SQL database.""" conn = sqlite3.connect('network_data.db') query = """ SELECT source, target, weight FROM edges WHERE network_id = ? """ df = pd.read_sql_query(query, conn, params=[network_id]) conn.close() # Create NetworkX Graph from edge list G = nx.from_pandas_edgelist(df, 'source', 'target', 'weight', create_using=nx.Graph) return G # Load and create visualization G = load_network_from_db('network1') analysis = analyze_network(G) visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) fig.write_html('network_from_db.html') # For MySQL/PostgreSQL: # import mysql.connector # conn = mysql.connector.connect( # host='localhost', # user='username', # password='password', # database='network_db' # )

Integration with REST API

Load network data from REST API endpoint:

# Load network data from REST API import requests import pandas as pd import networkx as nx from network_visualizer import NetworkVisualizer from network_analysis import analyze_network def load_network_from_api(): """Load network data from REST API.""" response = requests.get( 'https://api.example.com/network', headers={'Authorization': 'Bearer YOUR_TOKEN'} ) data = response.json() df = pd.DataFrame(data['edges']) # Ensure required columns exist G = nx.from_pandas_edgelist(df, 'source', 'target', 'weight', create_using=nx.Graph) return G # Load and create visualization G = load_network_from_api() analysis = analyze_network(G) visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) fig.write_html('network_from_api.html') # For real-time updates, refresh data periodically: import time while True: G = load_network_from_api() analysis = analyze_network(G) fig = visualizer.create_network_graph(G, analysis) fig.write_html('network_live.html') time.sleep(300) # Update every 5 minutes

Embedding Networks in Web Pages

Embed interactive network graphs in existing websites:

# Embed Chart in Web Page: # Option 1: Direct HTML embedding # The generated HTML files are standalone and can be embedded: <iframe src="path/to/network_graph.html" width="100%" height="700px" frameborder="0"> </iframe> # Option 2: Use Plotly's HTML output from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer G = create_sample_network() analysis = analyze_network(G) visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) # Get HTML div and script html_div = fig.to_html(include_plotlyjs='cdn', div_id='network-div') # Embed in your HTML page: # <div id="network-div"></div> # <script>...plotly.js code...</script> # Option 3: Serve HTML files via web server # Place HTML files in web server directory # Access via: https://yourdomain.com/networks/network_graph.html # Option 4: Use Flask/Django to serve networks from flask import Flask, send_file from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer app = Flask(__name__) @app.route('/network') def show_network(): G = create_sample_network() analysis = analyze_network(G) visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) fig.write_html('static/network_graph.html') return send_file('static/network_graph.html')

Sharing Charts

Share interactive charts with others:

# Sharing Network Options: # 1. Share HTML files directly # - HTML files are standalone and portable # - Can be opened in any browser # - No server required # - Share via email, cloud storage, etc. # 2. Upload to web hosting # - Upload HTML files to web server # - Share URL with team members # - Files remain interactive # 3. Export as images (for reports) from network_analysis import create_sample_network, analyze_network from network_visualizer import NetworkVisualizer G = create_sample_network() analysis = analyze_network(G) visualizer = NetworkVisualizer() fig = visualizer.create_network_graph(G, analysis) fig.write_image('network_graph.png', width=1920, height=1080) # Use in presentations, reports, documents # 4. Use Plotly Chart Studio (optional) # Upload to Plotly Chart Studio for cloud hosting # fig.write_html('network_graph.html') # Then upload to chart-studio.plotly.com # 5. GitHub Pages # - Push HTML files to GitHub repository # - Enable GitHub Pages # - Share public URL

Contact Information | Support | Get Help | Contact RSK World

Get in Touch

Developer: Molla Samser
Designer & Tester: Rima Khatun

rskworld.in
help@rskworld.in support@rskworld.in
+91 93305 39277

License | Open Source License | Project License

This project is for educational purposes only. See LICENSE file for more details.

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer