lanet-vi 5.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lanet_vi-5.0.0/PKG-INFO +305 -0
- lanet_vi-5.0.0/README.md +261 -0
- lanet_vi-5.0.0/pyproject.toml +91 -0
- lanet_vi-5.0.0/src/lanet_vi/__init__.py +30 -0
- lanet_vi-5.0.0/src/lanet_vi/cli.py +500 -0
- lanet_vi-5.0.0/src/lanet_vi/community/__init__.py +15 -0
- lanet_vi-5.0.0/src/lanet_vi/community/base.py +105 -0
- lanet_vi-5.0.0/src/lanet_vi/community/louvain.py +196 -0
- lanet_vi-5.0.0/src/lanet_vi/core/__init__.py +0 -0
- lanet_vi-5.0.0/src/lanet_vi/core/network.py +385 -0
- lanet_vi-5.0.0/src/lanet_vi/decomposition/__init__.py +0 -0
- lanet_vi-5.0.0/src/lanet_vi/decomposition/dcores.py +238 -0
- lanet_vi-5.0.0/src/lanet_vi/decomposition/kcores.py +266 -0
- lanet_vi-5.0.0/src/lanet_vi/decomposition/kdenses.py +261 -0
- lanet_vi-5.0.0/src/lanet_vi/generators/__init__.py +19 -0
- lanet_vi-5.0.0/src/lanet_vi/generators/random_graphs.py +255 -0
- lanet_vi-5.0.0/src/lanet_vi/io/__init__.py +0 -0
- lanet_vi-5.0.0/src/lanet_vi/io/config_loader.py +98 -0
- lanet_vi-5.0.0/src/lanet_vi/io/readers.py +293 -0
- lanet_vi-5.0.0/src/lanet_vi/io/writers.py +325 -0
- lanet_vi-5.0.0/src/lanet_vi/logging_config.py +77 -0
- lanet_vi-5.0.0/src/lanet_vi/metrics/__init__.py +25 -0
- lanet_vi-5.0.0/src/lanet_vi/metrics/information.py +271 -0
- lanet_vi-5.0.0/src/lanet_vi/metrics/similarity.py +287 -0
- lanet_vi-5.0.0/src/lanet_vi/models/__init__.py +0 -0
- lanet_vi-5.0.0/src/lanet_vi/models/config.py +317 -0
- lanet_vi-5.0.0/src/lanet_vi/models/graph.py +225 -0
- lanet_vi-5.0.0/src/lanet_vi/py.typed +0 -0
- lanet_vi-5.0.0/src/lanet_vi/visualization/__init__.py +0 -0
- lanet_vi-5.0.0/src/lanet_vi/visualization/circular_average.py +195 -0
- lanet_vi-5.0.0/src/lanet_vi/visualization/colors.py +202 -0
- lanet_vi-5.0.0/src/lanet_vi/visualization/community_viz.py +266 -0
- lanet_vi-5.0.0/src/lanet_vi/visualization/layout.py +706 -0
- lanet_vi-5.0.0/src/lanet_vi/visualization/matplotlib_renderer.py +552 -0
- lanet_vi-5.0.0/src/lanet_vi/visualization/spatial_index.py +289 -0
- lanet_vi-5.0.0/src/lanet_vi/visualization/spiral_layout.py +263 -0
lanet_vi-5.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: lanet-vi
|
|
3
|
+
Version: 5.0.0
|
|
4
|
+
Summary: Large scale network visualization using k-core, k-dense, and d-core decomposition with community detection
|
|
5
|
+
Keywords: network,visualization,k-core,k-dense,graph-analysis
|
|
6
|
+
Author: Esteban Carisimo, Mariano Beiró, J. Ignacio Alvarez-Hamelin
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Dist: networkx>=3.0
|
|
17
|
+
Requires-Dist: pandas>=2.0
|
|
18
|
+
Requires-Dist: polars>=0.20
|
|
19
|
+
Requires-Dist: pydantic>=2.0
|
|
20
|
+
Requires-Dist: matplotlib>=3.7
|
|
21
|
+
Requires-Dist: numpy>=1.24
|
|
22
|
+
Requires-Dist: scipy>=1.10
|
|
23
|
+
Requires-Dist: scikit-learn>=1.3
|
|
24
|
+
Requires-Dist: requests>=2.31
|
|
25
|
+
Requires-Dist: typer>=0.9
|
|
26
|
+
Requires-Dist: rich>=13.0
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Requires-Dist: pytest>=7.0 ; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0 ; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.1 ; extra == 'dev'
|
|
31
|
+
Requires-Dist: mypy>=1.0 ; extra == 'dev'
|
|
32
|
+
Requires-Dist: ipython>=8.0 ; extra == 'dev'
|
|
33
|
+
Requires-Dist: jupyter>=1.0 ; extra == 'dev'
|
|
34
|
+
Requires-Dist: plotly>=5.0 ; extra == 'interactive'
|
|
35
|
+
Requires-Dist: ipywidgets>=8.0 ; extra == 'interactive'
|
|
36
|
+
Requires-Python: >=3.9
|
|
37
|
+
Project-URL: Documentation, https://github.com/conexdat/LaNet-vi/tree/main/docs
|
|
38
|
+
Project-URL: Homepage, https://github.com/conexdat/LaNet-vi
|
|
39
|
+
Project-URL: Issues, https://github.com/conexdat/LaNet-vi/issues
|
|
40
|
+
Project-URL: Repository, https://github.com/conexdat/LaNet-vi.git
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Provides-Extra: interactive
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# LaNet-vi 5.0
|
|
46
|
+
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
[](https://pypi.org/project/lanet-vi/)
|
|
49
|
+
[](LICENSE)
|
|
50
|
+
[](https://github.com/conexdat/LaNet-vi/actions)
|
|
51
|
+
[](https://github.com/astral-sh/uv)
|
|
52
|
+
|
|
53
|
+
**Large-scale network visualization using k-core decomposition**
|
|
54
|
+
|
|
55
|
+
LaNet-vi is a Python package for visualizing large-scale networks through hierarchical decomposition algorithms. It reveals network structure by identifying the k-core hierarchy - from peripheral nodes to densely connected cores.
|
|
56
|
+
|
|
57
|
+
## What is K-Core Decomposition?
|
|
58
|
+
|
|
59
|
+
K-core decomposition identifies hierarchical layers in networks where each k-core is a maximal subgraph with all nodes having at least k neighbors. This creates an "onion-like" structure revealing:
|
|
60
|
+
|
|
61
|
+
- **Core nodes** (high k): Densely connected, central, resilient
|
|
62
|
+
- **Peripheral nodes** (low k): Loosely connected, on the edges
|
|
63
|
+
- **Intermediate layers**: Transitional connectivity
|
|
64
|
+
|
|
65
|
+
Perfect for analyzing social networks, internet topology, biological networks, and collaboration graphs.
|
|
66
|
+
|
|
67
|
+
📖 **[Learn more about k-core concepts →](docs/concepts.md)**
|
|
68
|
+
|
|
69
|
+
## Features
|
|
70
|
+
|
|
71
|
+
- **K-core, k-dense, and d-core decomposition** algorithms
|
|
72
|
+
- **Circular hierarchical layout** with smooth rings and gradient edge coloring
|
|
73
|
+
- **High-performance rendering** for networks with millions of nodes
|
|
74
|
+
- **Flexible I/O** supporting compressed formats (gzip, bz2)
|
|
75
|
+
- **Community detection** with Louvain and modularity algorithms
|
|
76
|
+
- **Python API and CLI** with full configurability
|
|
77
|
+
- **Publication-ready** visualizations with auto-scaling legends
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Using uv (recommended)
|
|
83
|
+
uv pip install lanet-vi
|
|
84
|
+
|
|
85
|
+
# Or with pip
|
|
86
|
+
pip install lanet-vi
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Quick Start
|
|
90
|
+
|
|
91
|
+
### Command Line
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Visualize a network
|
|
95
|
+
lanet-vi visualize --input network.txt --output viz.png
|
|
96
|
+
|
|
97
|
+
# With custom settings
|
|
98
|
+
lanet-vi visualize --input network.txt \
|
|
99
|
+
--width 2400 --height 2400 \
|
|
100
|
+
--background black \
|
|
101
|
+
--output viz.png
|
|
102
|
+
|
|
103
|
+
# Generate configuration template
|
|
104
|
+
lanet-vi config my_config.yaml
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Python API
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
import networkx as nx
|
|
111
|
+
from lanet_vi import Network, LaNetConfig, DecompositionType
|
|
112
|
+
|
|
113
|
+
# Load network
|
|
114
|
+
G = nx.karate_club_graph()
|
|
115
|
+
|
|
116
|
+
# Decompose and visualize
|
|
117
|
+
config = LaNetConfig()
|
|
118
|
+
net = Network(G, config)
|
|
119
|
+
net.decompose(DecompositionType.KCORES)
|
|
120
|
+
net.visualize("output.png")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Example: Internet Topology
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from lanet_vi.io.readers import read_caida_snapshot
|
|
127
|
+
from lanet_vi import Network, LaNetConfig
|
|
128
|
+
|
|
129
|
+
# Download and visualize CAIDA AS-relationships data
|
|
130
|
+
graph, _ = read_caida_snapshot(
|
|
131
|
+
"https://publicdata.caida.org/datasets/as-relationships/serial-1/20170101.as-rel.txt.bz2"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
config = LaNetConfig() # Uses optimized defaults
|
|
135
|
+
net = Network(graph, config)
|
|
136
|
+
net.decompose()
|
|
137
|
+
net.visualize("internet_topology.png")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**See example output:** [examples/outputs/caida_as_relationships_kcores.png](examples/outputs/caida_as_relationships_kcores.png)
|
|
141
|
+
|
|
142
|
+
The visualization reveals the Internet's hierarchical structure with Tier-1 providers in the center and stub networks at the periphery.
|
|
143
|
+
|
|
144
|
+
## Example Visualizations
|
|
145
|
+
|
|
146
|
+
<p align="center">
|
|
147
|
+
<img src="examples/outputs/caida_as_relationships_kcores.png" width="45%" alt="K-cores decomposition">
|
|
148
|
+
<img src="examples/outputs/caida_as_relationships_kdenses.png" width="45%" alt="K-denses decomposition">
|
|
149
|
+
<br>
|
|
150
|
+
<em>CAIDA AS-Relationships Network (56,345 nodes): K-cores (left) vs K-denses (right)</em>
|
|
151
|
+
</p>
|
|
152
|
+
|
|
153
|
+
The visualizations reveal the hierarchical structure of the Internet, with densely connected core networks (red/orange) at the center and peripheral networks (blue/purple) at the edges. K-cores use degree-based decomposition while k-denses use triangle-based decomposition, highlighting different structural properties.
|
|
154
|
+
|
|
155
|
+
## Input Format
|
|
156
|
+
|
|
157
|
+
Edge list (space or tab separated):
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
# Comments start with #
|
|
161
|
+
0 1
|
|
162
|
+
1 2
|
|
163
|
+
2 0
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Weighted networks:
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
0 1 2.5
|
|
170
|
+
1 2 3.0
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Supports `.txt`, `.txt.gz`, `.txt.bz2` formats.
|
|
174
|
+
|
|
175
|
+
## Common Options
|
|
176
|
+
|
|
177
|
+
**Decomposition:**
|
|
178
|
+
- `--decomp [kcores|kdenses|dcores]`: Decomposition algorithm (default: kcores)
|
|
179
|
+
- `--weighted`: Graph has edge weights
|
|
180
|
+
- `--directed`: Graph is directed (required for dcores)
|
|
181
|
+
|
|
182
|
+
**Visualization:**
|
|
183
|
+
- `--width`, `--height`: Image dimensions (default: 2400x2400)
|
|
184
|
+
- `--background [black|white]`: Background color (default: black)
|
|
185
|
+
- `--epsilon FLOAT`: Ring spread (default: 0.40)
|
|
186
|
+
- `--edges-percent FLOAT`: Percentage of edges to show (default: 0.5)
|
|
187
|
+
- `--edge-alpha FLOAT`: Edge transparency (default: 0.6)
|
|
188
|
+
|
|
189
|
+
**Output:**
|
|
190
|
+
- `--output PATH`: Visualization file (PNG, PDF, SVG)
|
|
191
|
+
- `--cores-file PATH`: Export decomposition data (CSV or JSON)
|
|
192
|
+
|
|
193
|
+
**Full CLI reference:** See [docs/usage.md](docs/usage.md#using-lanet-vi-via-command-line)
|
|
194
|
+
|
|
195
|
+
## Configuration
|
|
196
|
+
|
|
197
|
+
Generate a template:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
lanet-vi config my_config.yaml
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Example configuration:
|
|
204
|
+
|
|
205
|
+
```yaml
|
|
206
|
+
visualization:
|
|
207
|
+
background: black
|
|
208
|
+
width: 2400
|
|
209
|
+
height: 2400
|
|
210
|
+
epsilon: 0.40
|
|
211
|
+
edges_percent: 0.5
|
|
212
|
+
edge_alpha: 0.6
|
|
213
|
+
|
|
214
|
+
layout:
|
|
215
|
+
seed: 0
|
|
216
|
+
|
|
217
|
+
decomposition:
|
|
218
|
+
decomp_type: kcores
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Use it:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
lanet-vi visualize --input network.txt --config my_config.yaml
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Documentation
|
|
228
|
+
|
|
229
|
+
- **[K-Core Concepts](docs/concepts.md)** - Understanding k-core decomposition
|
|
230
|
+
- **[Visualization Guide](docs/visualization.md)** - How the plots work (colors, sizing, layout)
|
|
231
|
+
- **[Usage Guide](docs/usage.md)** - Detailed Python API and CLI examples
|
|
232
|
+
- **[Examples](examples/)** - Working examples with real datasets
|
|
233
|
+
|
|
234
|
+
## Advanced Features
|
|
235
|
+
|
|
236
|
+
### Community Detection
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
lanet-vi visualize --input network.txt \
|
|
240
|
+
--detect-communities \
|
|
241
|
+
--draw-community-boundaries \
|
|
242
|
+
--output communities.png
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Random Graph Generation
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
lanet-vi generate --output test.txt \
|
|
249
|
+
--model barabasi-albert \
|
|
250
|
+
--nodes 1000 --edges 3
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### D-Cores (Directed Networks)
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
lanet-vi visualize --input citations.txt \
|
|
257
|
+
--directed --decomp dcores \
|
|
258
|
+
--output dcores.png
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Performance Tips
|
|
262
|
+
|
|
263
|
+
**Large networks (>100K nodes):**
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
config.visualization.edges_percent = 0.1 # Show 10% of edges
|
|
267
|
+
config.visualization.edge_alpha = 0.5
|
|
268
|
+
config.visualization.node_size_scale = 0.4
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Publication quality:**
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
config.visualization.width = 3600
|
|
275
|
+
config.visualization.height = 3600
|
|
276
|
+
config.visualization.background = "white"
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Development
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
git clone https://github.com/conexdat/LaNet-vi.git
|
|
283
|
+
cd LaNet-vi
|
|
284
|
+
uv sync --all-extras
|
|
285
|
+
uv run pytest
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Citation
|
|
289
|
+
|
|
290
|
+
If you use LaNet-vi in your research, please cite:
|
|
291
|
+
|
|
292
|
+
- Alvarez-Hamelin, J.I., Dall'Asta, L., Barrat, A., Vespignani, A. (2006). "Large scale networks fingerprinting and visualization using the k-core decomposition". *Advances in Neural Information Processing Systems 18*.
|
|
293
|
+
|
|
294
|
+
- Beiró, M.G., Alvarez-Hamelin, J.I., Busch, J.R. (2008). "A low complexity visualization tool that helps to perform complex systems analysis". *New Journal of Physics*.
|
|
295
|
+
|
|
296
|
+
## License
|
|
297
|
+
|
|
298
|
+
MIT License
|
|
299
|
+
|
|
300
|
+
## Authors
|
|
301
|
+
|
|
302
|
+
- Esteban Carisimo (Python implementation)
|
|
303
|
+
- Mariano Beiró (original C++ version)
|
|
304
|
+
- J. Ignacio Alvarez-Hamelin (original C++ version)
|
|
305
|
+
|
lanet_vi-5.0.0/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# LaNet-vi 5.0
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](https://pypi.org/project/lanet-vi/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/conexdat/LaNet-vi/actions)
|
|
7
|
+
[](https://github.com/astral-sh/uv)
|
|
8
|
+
|
|
9
|
+
**Large-scale network visualization using k-core decomposition**
|
|
10
|
+
|
|
11
|
+
LaNet-vi is a Python package for visualizing large-scale networks through hierarchical decomposition algorithms. It reveals network structure by identifying the k-core hierarchy - from peripheral nodes to densely connected cores.
|
|
12
|
+
|
|
13
|
+
## What is K-Core Decomposition?
|
|
14
|
+
|
|
15
|
+
K-core decomposition identifies hierarchical layers in networks where each k-core is a maximal subgraph with all nodes having at least k neighbors. This creates an "onion-like" structure revealing:
|
|
16
|
+
|
|
17
|
+
- **Core nodes** (high k): Densely connected, central, resilient
|
|
18
|
+
- **Peripheral nodes** (low k): Loosely connected, on the edges
|
|
19
|
+
- **Intermediate layers**: Transitional connectivity
|
|
20
|
+
|
|
21
|
+
Perfect for analyzing social networks, internet topology, biological networks, and collaboration graphs.
|
|
22
|
+
|
|
23
|
+
📖 **[Learn more about k-core concepts →](docs/concepts.md)**
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- **K-core, k-dense, and d-core decomposition** algorithms
|
|
28
|
+
- **Circular hierarchical layout** with smooth rings and gradient edge coloring
|
|
29
|
+
- **High-performance rendering** for networks with millions of nodes
|
|
30
|
+
- **Flexible I/O** supporting compressed formats (gzip, bz2)
|
|
31
|
+
- **Community detection** with Louvain and modularity algorithms
|
|
32
|
+
- **Python API and CLI** with full configurability
|
|
33
|
+
- **Publication-ready** visualizations with auto-scaling legends
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Using uv (recommended)
|
|
39
|
+
uv pip install lanet-vi
|
|
40
|
+
|
|
41
|
+
# Or with pip
|
|
42
|
+
pip install lanet-vi
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
### Command Line
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Visualize a network
|
|
51
|
+
lanet-vi visualize --input network.txt --output viz.png
|
|
52
|
+
|
|
53
|
+
# With custom settings
|
|
54
|
+
lanet-vi visualize --input network.txt \
|
|
55
|
+
--width 2400 --height 2400 \
|
|
56
|
+
--background black \
|
|
57
|
+
--output viz.png
|
|
58
|
+
|
|
59
|
+
# Generate configuration template
|
|
60
|
+
lanet-vi config my_config.yaml
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Python API
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import networkx as nx
|
|
67
|
+
from lanet_vi import Network, LaNetConfig, DecompositionType
|
|
68
|
+
|
|
69
|
+
# Load network
|
|
70
|
+
G = nx.karate_club_graph()
|
|
71
|
+
|
|
72
|
+
# Decompose and visualize
|
|
73
|
+
config = LaNetConfig()
|
|
74
|
+
net = Network(G, config)
|
|
75
|
+
net.decompose(DecompositionType.KCORES)
|
|
76
|
+
net.visualize("output.png")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Example: Internet Topology
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from lanet_vi.io.readers import read_caida_snapshot
|
|
83
|
+
from lanet_vi import Network, LaNetConfig
|
|
84
|
+
|
|
85
|
+
# Download and visualize CAIDA AS-relationships data
|
|
86
|
+
graph, _ = read_caida_snapshot(
|
|
87
|
+
"https://publicdata.caida.org/datasets/as-relationships/serial-1/20170101.as-rel.txt.bz2"
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
config = LaNetConfig() # Uses optimized defaults
|
|
91
|
+
net = Network(graph, config)
|
|
92
|
+
net.decompose()
|
|
93
|
+
net.visualize("internet_topology.png")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**See example output:** [examples/outputs/caida_as_relationships_kcores.png](examples/outputs/caida_as_relationships_kcores.png)
|
|
97
|
+
|
|
98
|
+
The visualization reveals the Internet's hierarchical structure with Tier-1 providers in the center and stub networks at the periphery.
|
|
99
|
+
|
|
100
|
+
## Example Visualizations
|
|
101
|
+
|
|
102
|
+
<p align="center">
|
|
103
|
+
<img src="examples/outputs/caida_as_relationships_kcores.png" width="45%" alt="K-cores decomposition">
|
|
104
|
+
<img src="examples/outputs/caida_as_relationships_kdenses.png" width="45%" alt="K-denses decomposition">
|
|
105
|
+
<br>
|
|
106
|
+
<em>CAIDA AS-Relationships Network (56,345 nodes): K-cores (left) vs K-denses (right)</em>
|
|
107
|
+
</p>
|
|
108
|
+
|
|
109
|
+
The visualizations reveal the hierarchical structure of the Internet, with densely connected core networks (red/orange) at the center and peripheral networks (blue/purple) at the edges. K-cores use degree-based decomposition while k-denses use triangle-based decomposition, highlighting different structural properties.
|
|
110
|
+
|
|
111
|
+
## Input Format
|
|
112
|
+
|
|
113
|
+
Edge list (space or tab separated):
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
# Comments start with #
|
|
117
|
+
0 1
|
|
118
|
+
1 2
|
|
119
|
+
2 0
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Weighted networks:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
0 1 2.5
|
|
126
|
+
1 2 3.0
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Supports `.txt`, `.txt.gz`, `.txt.bz2` formats.
|
|
130
|
+
|
|
131
|
+
## Common Options
|
|
132
|
+
|
|
133
|
+
**Decomposition:**
|
|
134
|
+
- `--decomp [kcores|kdenses|dcores]`: Decomposition algorithm (default: kcores)
|
|
135
|
+
- `--weighted`: Graph has edge weights
|
|
136
|
+
- `--directed`: Graph is directed (required for dcores)
|
|
137
|
+
|
|
138
|
+
**Visualization:**
|
|
139
|
+
- `--width`, `--height`: Image dimensions (default: 2400x2400)
|
|
140
|
+
- `--background [black|white]`: Background color (default: black)
|
|
141
|
+
- `--epsilon FLOAT`: Ring spread (default: 0.40)
|
|
142
|
+
- `--edges-percent FLOAT`: Percentage of edges to show (default: 0.5)
|
|
143
|
+
- `--edge-alpha FLOAT`: Edge transparency (default: 0.6)
|
|
144
|
+
|
|
145
|
+
**Output:**
|
|
146
|
+
- `--output PATH`: Visualization file (PNG, PDF, SVG)
|
|
147
|
+
- `--cores-file PATH`: Export decomposition data (CSV or JSON)
|
|
148
|
+
|
|
149
|
+
**Full CLI reference:** See [docs/usage.md](docs/usage.md#using-lanet-vi-via-command-line)
|
|
150
|
+
|
|
151
|
+
## Configuration
|
|
152
|
+
|
|
153
|
+
Generate a template:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
lanet-vi config my_config.yaml
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Example configuration:
|
|
160
|
+
|
|
161
|
+
```yaml
|
|
162
|
+
visualization:
|
|
163
|
+
background: black
|
|
164
|
+
width: 2400
|
|
165
|
+
height: 2400
|
|
166
|
+
epsilon: 0.40
|
|
167
|
+
edges_percent: 0.5
|
|
168
|
+
edge_alpha: 0.6
|
|
169
|
+
|
|
170
|
+
layout:
|
|
171
|
+
seed: 0
|
|
172
|
+
|
|
173
|
+
decomposition:
|
|
174
|
+
decomp_type: kcores
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Use it:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
lanet-vi visualize --input network.txt --config my_config.yaml
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Documentation
|
|
184
|
+
|
|
185
|
+
- **[K-Core Concepts](docs/concepts.md)** - Understanding k-core decomposition
|
|
186
|
+
- **[Visualization Guide](docs/visualization.md)** - How the plots work (colors, sizing, layout)
|
|
187
|
+
- **[Usage Guide](docs/usage.md)** - Detailed Python API and CLI examples
|
|
188
|
+
- **[Examples](examples/)** - Working examples with real datasets
|
|
189
|
+
|
|
190
|
+
## Advanced Features
|
|
191
|
+
|
|
192
|
+
### Community Detection
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
lanet-vi visualize --input network.txt \
|
|
196
|
+
--detect-communities \
|
|
197
|
+
--draw-community-boundaries \
|
|
198
|
+
--output communities.png
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Random Graph Generation
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
lanet-vi generate --output test.txt \
|
|
205
|
+
--model barabasi-albert \
|
|
206
|
+
--nodes 1000 --edges 3
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### D-Cores (Directed Networks)
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
lanet-vi visualize --input citations.txt \
|
|
213
|
+
--directed --decomp dcores \
|
|
214
|
+
--output dcores.png
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Performance Tips
|
|
218
|
+
|
|
219
|
+
**Large networks (>100K nodes):**
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
config.visualization.edges_percent = 0.1 # Show 10% of edges
|
|
223
|
+
config.visualization.edge_alpha = 0.5
|
|
224
|
+
config.visualization.node_size_scale = 0.4
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Publication quality:**
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
config.visualization.width = 3600
|
|
231
|
+
config.visualization.height = 3600
|
|
232
|
+
config.visualization.background = "white"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
git clone https://github.com/conexdat/LaNet-vi.git
|
|
239
|
+
cd LaNet-vi
|
|
240
|
+
uv sync --all-extras
|
|
241
|
+
uv run pytest
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Citation
|
|
245
|
+
|
|
246
|
+
If you use LaNet-vi in your research, please cite:
|
|
247
|
+
|
|
248
|
+
- Alvarez-Hamelin, J.I., Dall'Asta, L., Barrat, A., Vespignani, A. (2006). "Large scale networks fingerprinting and visualization using the k-core decomposition". *Advances in Neural Information Processing Systems 18*.
|
|
249
|
+
|
|
250
|
+
- Beiró, M.G., Alvarez-Hamelin, J.I., Busch, J.R. (2008). "A low complexity visualization tool that helps to perform complex systems analysis". *New Journal of Physics*.
|
|
251
|
+
|
|
252
|
+
## License
|
|
253
|
+
|
|
254
|
+
MIT License
|
|
255
|
+
|
|
256
|
+
## Authors
|
|
257
|
+
|
|
258
|
+
- Esteban Carisimo (Python implementation)
|
|
259
|
+
- Mariano Beiró (original C++ version)
|
|
260
|
+
- J. Ignacio Alvarez-Hamelin (original C++ version)
|
|
261
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "lanet-vi"
|
|
3
|
+
version = "5.0.0"
|
|
4
|
+
description = "Large scale network visualization using k-core, k-dense, and d-core decomposition with community detection"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Esteban Carisimo"},
|
|
8
|
+
{ name = "Mariano Beiró" },
|
|
9
|
+
{ name = "J. Ignacio Alvarez-Hamelin" }
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"networkx>=3.0",
|
|
14
|
+
"pandas>=2.0",
|
|
15
|
+
"polars>=0.20",
|
|
16
|
+
"pydantic>=2.0",
|
|
17
|
+
"matplotlib>=3.7",
|
|
18
|
+
"numpy>=1.24",
|
|
19
|
+
"scipy>=1.10",
|
|
20
|
+
"scikit-learn>=1.3",
|
|
21
|
+
"requests>=2.31",
|
|
22
|
+
"typer>=0.9",
|
|
23
|
+
"rich>=13.0",
|
|
24
|
+
"pyyaml>=6.0",
|
|
25
|
+
]
|
|
26
|
+
license = { text = "MIT" }
|
|
27
|
+
keywords = ["network", "visualization", "k-core", "k-dense", "graph-analysis"]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Intended Audience :: Science/Research",
|
|
31
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
32
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
33
|
+
"Programming Language :: Python :: 3.9",
|
|
34
|
+
"Programming Language :: Python :: 3.10",
|
|
35
|
+
"Programming Language :: Python :: 3.11",
|
|
36
|
+
"Programming Language :: Python :: 3.12",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/conexdat/LaNet-vi"
|
|
41
|
+
Repository = "https://github.com/conexdat/LaNet-vi.git"
|
|
42
|
+
Documentation = "https://github.com/conexdat/LaNet-vi/tree/main/docs"
|
|
43
|
+
Issues = "https://github.com/conexdat/LaNet-vi/issues"
|
|
44
|
+
|
|
45
|
+
[project.optional-dependencies]
|
|
46
|
+
dev = [
|
|
47
|
+
"pytest>=7.0",
|
|
48
|
+
"pytest-cov>=4.0",
|
|
49
|
+
"ruff>=0.1",
|
|
50
|
+
"mypy>=1.0",
|
|
51
|
+
"ipython>=8.0",
|
|
52
|
+
"jupyter>=1.0",
|
|
53
|
+
]
|
|
54
|
+
interactive = [
|
|
55
|
+
"plotly>=5.0",
|
|
56
|
+
"ipywidgets>=8.0",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[project.scripts]
|
|
60
|
+
lanet-vi = "lanet_vi.cli:main"
|
|
61
|
+
|
|
62
|
+
[build-system]
|
|
63
|
+
requires = ["uv_build>=0.8.0,<0.9"]
|
|
64
|
+
build-backend = "uv_build"
|
|
65
|
+
|
|
66
|
+
[tool.ruff]
|
|
67
|
+
line-length = 100
|
|
68
|
+
target-version = "py39"
|
|
69
|
+
|
|
70
|
+
[tool.ruff.lint]
|
|
71
|
+
select = ["E", "F", "I", "N", "W", "D"]
|
|
72
|
+
ignore = ["D100", "D104"]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint.pydocstyle]
|
|
75
|
+
convention = "numpy"
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint.pep8-naming]
|
|
78
|
+
ignore-names = ["G", "K1", "K2"]
|
|
79
|
+
|
|
80
|
+
[tool.mypy]
|
|
81
|
+
python_version = "3.9"
|
|
82
|
+
warn_return_any = true
|
|
83
|
+
warn_unused_configs = true
|
|
84
|
+
disallow_untyped_defs = true
|
|
85
|
+
|
|
86
|
+
[tool.pytest.ini_options]
|
|
87
|
+
testpaths = ["tests"]
|
|
88
|
+
python_files = "test_*.py"
|
|
89
|
+
python_classes = "Test*"
|
|
90
|
+
python_functions = "test_*"
|
|
91
|
+
addopts = "-v --cov=lanet_vi --cov-report=term-missing"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""LaNet-vi: Large scale network visualization using k-core and k-dense decomposition."""
|
|
2
|
+
|
|
3
|
+
__version__ = "4.0.0"
|
|
4
|
+
|
|
5
|
+
from lanet_vi.core.network import Network
|
|
6
|
+
from lanet_vi.io.config_loader import load_config_from_yaml, save_config_to_yaml
|
|
7
|
+
from lanet_vi.models.config import (
|
|
8
|
+
BackgroundColor,
|
|
9
|
+
ColorScheme,
|
|
10
|
+
DecompositionConfig,
|
|
11
|
+
DecompositionType,
|
|
12
|
+
GraphConfig,
|
|
13
|
+
LaNetConfig,
|
|
14
|
+
LayoutConfig,
|
|
15
|
+
VisualizationConfig,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"Network",
|
|
20
|
+
"LaNetConfig",
|
|
21
|
+
"GraphConfig",
|
|
22
|
+
"DecompositionConfig",
|
|
23
|
+
"VisualizationConfig",
|
|
24
|
+
"LayoutConfig",
|
|
25
|
+
"DecompositionType",
|
|
26
|
+
"ColorScheme",
|
|
27
|
+
"BackgroundColor",
|
|
28
|
+
"load_config_from_yaml",
|
|
29
|
+
"save_config_to_yaml",
|
|
30
|
+
]
|