This directory contains examples demonstrating LaNet-vi usage.
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.pyThe same example is on the docs site, under "Using LaNet-vi from NetworkX".
File: caida_example.py
Visualizes the CAIDA AS-Relationships dataset showing Internet topology at the Autonomous System (AS) level.
uv run python examples/caida_example.py- Downloads data from CAIDA public dataset (20251001 snapshot)
- Loads network using pandas-based edge list reader
- Computes k-core decomposition using NetworkX
- Generates visualization with optimized default settings
- Exports results to CSV file
- 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.)
caida_as_relationships_kcores.png- Visualization (seeoutputs/)caida_cores.csv- K-core values for each AS
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
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 seedData 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.
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.
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.
uv run python examples/caida_kdenses_example.py- Downloads data from CAIDA public dataset (20251001 snapshot)
- Loads network using pandas-based edge list reader
- Computes k-denses decomposition using triangle counting
- Generates visualization with optimized default settings
- Exports results to CSV file
- 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.)
caida_as_relationships_kdenses.png- Visualization (seeoutputs/)caida_denses.csv- K-dense values for each AS
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
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
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
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 seedData 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.
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.


