-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathbenchmark_layouts.py
More file actions
82 lines (66 loc) · 2.81 KB
/
Copy pathbenchmark_layouts.py
File metadata and controls
82 lines (66 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
Visualization Example: Layout Computation Benchmark
This example demonstrates how to benchmark different layout algorithms
for network visualization, particularly comparing:
1. Traditional force-directed layouts
2. Embedding-based layouts (using node2vec + dimensionality reduction)
Key Idea: Compute layout by first computing node embeddings, then
projecting them to 2D space using t-SNE or similar techniques.
This approach can be faster and produce better layouts for large networks
compared to traditional force-directed algorithms.
Note: This is a benchmark/comparison template. The actual implementation
would require adding specific benchmark code based on your needs.
Runtime: FAST (< 5 seconds) - Standalone example suitable for CI
"""
import sys
print("=" * 70)
print("LAYOUT ALGORITHM BENCHMARK")
print("=" * 70)
print("\nThis example is a template for benchmarking layout algorithms.")
print("\nTypical approaches to compare:")
print(" 1. Force-directed layouts (e.g., ForceAtlas2, Fruchterman-Reingold)")
print(" 2. Embedding-based layouts (e.g., Node2Vec + t-SNE)")
print(" 3. Spectral layouts")
print(" 4. Multilayer-specific layouts")
print("\nKey considerations for layout benchmarks:")
print(" - Runtime performance (seconds/iterations)")
print(" - Visual quality (edge crossings, node overlap)")
print(" - Scalability (performance with network size)")
print(" - Preservation of community structure")
print(" - Layout stability across runs")
print("\nSuggested workflow:")
print(" 1. Generate test networks of varying sizes")
print(" 2. Apply each layout algorithm")
print(" 3. Measure computation time")
print(" 4. Evaluate visual quality metrics")
print(" 5. Compare results")
print("\n" + "=" * 70)
print("To implement a full benchmark, add code to:")
print(" - Load or generate test networks")
print(" - Apply different layout algorithms")
print(" - Time each algorithm")
print(" - Visualize and compare results")
print("=" * 70)
# Example benchmark structure (pseudo-code):
print("\nExample benchmark structure:")
print("""
from py3plex.core import multinet, random_generators
from py3plex.visualization.multilayer import hairball_plot
import time
# Generate test network
network = random_generators.random_multilayer_ER(1000, 5, 0.01, directed=False)
# Benchmark 1: Force-directed layout
start = time.time()
hairball_plot(network.core_network, layout_algorithm="force",
layout_parameters={"iterations": 100}, show=False)
force_time = time.time() - start
print(f"Force-directed: {force_time:.2f}s")
# Benchmark 2: Embedding-based layout
# (Requires node2vec and t-SNE setup)
# start = time.time()
# ... embedding computation ...
# embedding_time = time.time() - start
# print(f"Embedding-based: {embedding_time:.2f}s")
# Compare quality metrics
# ... compute edge crossings, node overlap, etc. ...
""")