Topology Analysis¶
Network topology analysis tools.
Overview¶
The topology module provides specialized network topology analyses:
- Hub identification
- Bridge detection
- Star pattern recognition
- Articulation points
- Community structure
Modules¶
pypopart.stats.topology ¶
Network topology analysis for PyPopART.
This module provides functions for analyzing the topology of haplotype networks, including identifying star-like patterns, partitions, and ancestral nodes.
StarPattern
dataclass
¶
Partition
dataclass
¶
Represents a partition (connected component) in the network.
Source code in src/pypopart/stats/topology.py
AncestralNode
dataclass
¶
identify_star_patterns ¶
Identify star-like patterns in the network.
A star pattern has a central node connected to multiple leaves (nodes with degree 1).
Args: network: HaplotypeNetwork object min_leaves: Minimum number of leaves for a pattern to be considered
Returns:
| Type | Description |
|---|---|
List of StarPattern objects.
|
|
Source code in src/pypopart/stats/topology.py
detect_network_partitions ¶
Detect partitions (connected components) in the network.
Args: network: HaplotypeNetwork object
Returns:
| Type | Description |
|---|---|
List of Partition objects, sorted by size (descending).
|
|
Source code in src/pypopart/stats/topology.py
calculate_node_centrality ¶
calculate_node_centrality(
network: HaplotypeNetwork,
methods: Optional[List[str]] = None,
) -> Dict[str, Dict[str, float]]
Calculate various centrality measures for all nodes.
Args: network: HaplotypeNetwork object methods: List of centrality methods to calculate ('degree', 'betweenness', 'closeness', 'eigenvector') If None, calculates all methods
Returns:
| Type | Description |
|---|---|
Dictionary mapping node_id -> {method -> centrality_score}.
|
|
Source code in src/pypopart/stats/topology.py
identify_ancestral_nodes ¶
Identify potential ancestral nodes in the network.
Ancestral nodes are typically characterized by: - High frequency - High degree (many connections) - Central position in the network - High betweenness centrality
Args: network: HaplotypeNetwork object top_n: Number of top candidates to return
Returns:
| Type | Description |
|---|---|
List of AncestralNode objects, sorted by score (descending).
|
|
Source code in src/pypopart/stats/topology.py
calculate_topology_summary ¶
Create a comprehensive topology summary report.
Args: network: HaplotypeNetwork object
Returns:
| Type | Description |
|---|---|
Dictionary with topology analysis results.
|
|
Source code in src/pypopart/stats/topology.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
find_central_hub_nodes ¶
find_central_hub_nodes(
network: HaplotypeNetwork,
degree_threshold: Optional[int] = None,
) -> List[Tuple[str, int]]
Find hub nodes (nodes with high degree).
Args: network: HaplotypeNetwork object degree_threshold: Minimum degree to be considered a hub If None, uses mean degree + 1 std dev
Returns:
| Type | Description |
|---|---|
List of (node_id, degree) tuples, sorted by degree (descending).
|
|
Source code in src/pypopart/stats/topology.py
detect_bridges ¶
Detect bridge edges in the network.
A bridge is an edge whose removal would disconnect the network or increase the number of connected components.
Args: network: HaplotypeNetwork object
Returns:
| Type | Description |
|---|---|
List of (node1, node2) tuples representing bridge edges.
|
|
Source code in src/pypopart/stats/topology.py
identify_bottleneck_nodes ¶
Identify bottleneck nodes (articulation points with high betweenness).
Bottleneck nodes are those whose removal would significantly disrupt information flow in the network.
Args: network: HaplotypeNetwork object
Returns:
| Type | Description |
|---|---|
List of (node_id, betweenness_score) tuples, sorted by score (descending).
|
|