Skip to content

Latest commit

 

History

History
214 lines (143 loc) · 6.87 KB

README.md

File metadata and controls

214 lines (143 loc) · 6.87 KB

LaNet-vi Examples

This directory contains examples demonstrating LaNet-vi usage.

NetworkX Example

File: networkx_example.py

Draws a synthetic Internet topology of 2,000 autonomous systems (nx.random_internet_as_graph) twice on one figure: with NetworkX's nx.spring_layout, nodes colored by nx.core_number, and with lanet_vi.draw, rings by shell index. It also checks that LaNet-vi's shells match nx.core_number. No download is needed.

uv run python examples/networkx_example.py

A synthetic Internet AS graph drawn with nx.spring_layout and with lanet_vi.draw

The same example is on the docs site, under "Using LaNet-vi from NetworkX".

CAIDA AS-Relationships Example

File: caida_example.py

Visualizes the CAIDA AS-Relationships dataset showing Internet topology at the Autonomous System (AS) level.

Running the Example

uv run python examples/caida_example.py

What it Does

  1. Downloads data from CAIDA public dataset (20251001 snapshot)
  2. Loads network using pandas-based edge list reader
  3. Computes k-core decomposition using NetworkX
  4. Generates visualization with optimized default settings
  5. Exports results to CSV file

Network Statistics

  • Nodes: 78,370 Autonomous Systems
  • Edges: 489,407 AS relationships
  • K-core range: 1 to 149
  • Components: 71,890

(Numbers from the 20251001 snapshot; they change between snapshots.)

Output Files

  • caida_as_relationships_kcores.png - Visualization (see outputs/)
  • caida_cores.csv - K-core values for each AS

Interpretation

The visualization reveals the hierarchical structure of the Internet:

Inner core (red/orange, k≈100-149):

  • Tier-1 backbone providers (Level3, Telia)
  • Hypergiant networks (Google, AWS, Cloudflare, Microsoft)
  • Dense interconnection
  • Critical infrastructure

Middle rings (yellow/green, k≈20-100):

  • Regional and national ISPs
  • Medium-sized content providers
  • Transit providers
  • Moderate connectivity

Outer rings (blue/purple, k=1-20):

  • Stub networks and end-user networks
  • Small ISPs and organizations
  • Edge of the network
  • Sparse connections

Customization

The example uses optimized default settings. To customize:

from lanet_vi.models.config import CoordDistributionAlgorithm

config = LaNetConfig()

# Adjust visualization
config.visualization.width = 3600  # Higher resolution
config.visualization.edges_percent = 0.3  # Fewer edges (default 0.5)
config.layout.coord_distribution = CoordDistributionAlgorithm.POWER  # circle packing

# Adjust layout
config.layout.seed = 42  # Different random seed

Data Source

Data is downloaded from: https://publicdata.caida.org/datasets/as-relationships/

The CAIDA AS Relationships Dataset provides inferred relationships between Autonomous Systems based on BGP routing data.

Example Output

CAIDA AS-Relationships K-Core Visualization

The visualization clearly shows the onion-like structure of the Internet, with a dense core of highly interconnected backbone providers and an enormous periphery of loosely connected stub networks.

CAIDA AS-Relationships K-Denses Example

File: caida_kdenses_example.py

Visualizes the same CAIDA AS-Relationships dataset using k-denses (m-core) decomposition, which reveals tightly-knit communities based on triangle density rather than degree.

Running the Example

uv run python examples/caida_kdenses_example.py

What it Does

  1. Downloads data from CAIDA public dataset (20251001 snapshot)
  2. Loads network using pandas-based edge list reader
  3. Computes k-denses decomposition using triangle counting
  4. Generates visualization with optimized default settings
  5. Exports results to CSV file

Network Statistics

  • Nodes: 78,370 Autonomous Systems
  • Edges: 489,407 AS relationships
  • K-dense range: 2 to 105
  • Components: 66,396

(Numbers from the 20251001 snapshot; they change between snapshots.)

Output Files

  • caida_as_relationships_kdenses.png - Visualization (see outputs/)
  • caida_denses.csv - K-dense values for each AS

K-Denses vs K-Cores

K-cores (degree-based):

  • Identifies hierarchical structure
  • Node in k-core if it has ≥k neighbors
  • Wide range of shells (1-149 for this dataset)
  • Shows overall connectivity patterns

K-denses (triangle-based):

  • Identifies cohesive communities
  • Edge in k-dense if it closes ≥k−2 triangles within the k-dense; a node takes its densest edge
  • Narrower range of shells (2-105 for this dataset; the legend counts them as m-cores, k−2, so 0-103)
  • Reveals tightly-knit groups with strong interconnections

Interpretation

The k-denses visualization reveals cohesive communities in Internet topology:

Inner core (red/orange, k≈70-105):

  • Most densely interconnected AS groups
  • Hypergiants and Tier-1 providers forming tight meshes
  • High triangle density (many mutual peering relationships)
  • Critical infrastructure with redundant paths

Middle rings (yellow/green, k≈20-70):

  • Regional ISP communities
  • Transit provider clusters
  • Moderate triangle density
  • Local interconnection hubs

Outer rings (blue/purple, k=2-20):

  • Peripheral AS groups
  • Stub networks with minimal peering
  • Low triangle density
  • Edge communities

Comparison with K-Cores

K-denses produces fewer shells than k-cores for the same network (2-105 vs 1-149) and pushes most ASes to the periphery (59% of the ASes are in no triangle at all and sit at k=2), indicating that triangle-based decomposition is more selective. While k-cores shows the broad hierarchical structure, k-denses highlights where ASes form tightly-knit communities with mutual relationships.

For Internet topology analysis:

  • Use k-cores to understand overall hierarchical structure
  • Use k-denses to identify cohesive peering communities

Customization

The example uses optimized default settings. To customize:

from lanet_vi.models.config import CoordDistributionAlgorithm

config = LaNetConfig()

# Adjust visualization
config.visualization.width = 3600  # Higher resolution
config.visualization.edges_percent = 0.3  # Fewer edges (default 0.5)
config.layout.coord_distribution = CoordDistributionAlgorithm.POWER  # circle packing

# Adjust layout
config.layout.seed = 42  # Different random seed

Data Source

Data is downloaded from: https://publicdata.caida.org/datasets/as-relationships/

The CAIDA AS Relationships Dataset provides inferred relationships between Autonomous Systems based on BGP routing data.

Example Output

CAIDA AS-Relationships K-Denses Visualization

The visualization reveals cohesive communities in the Internet's AS topology, with a concentrated core of ASes that participate in many mutual peering triangles and a periphery of loosely connected stub networks.