topolib.visualization package
Submodules
topolib.visualization.mapview module
MapView class for visualizing network topologies.
This module provides visualization methods for Topology objects using Folium.
- class topolib.visualization.mapview.MapView(topology: Topology)
Bases:
objectProvides interactive visualization methods for Topology objects using Folium.
This class creates interactive HTML maps with OpenStreetMap tiles, displaying network nodes as clickable markers and links as lines between them.
- export_html(filename: str, show_node_ids: bool = False) None
Export the map as a standalone HTML file.
- Parameters:
filename (str) – Output HTML file path.
show_node_ids (bool) – If True, displays node IDs on the map (default: False).
- export_map_png(filename: str, width: int = 1920, height: int = 1080, wait_time: float = 1.0, paper_format: bool = False, show_node_ids: bool = False) None
Export the map as a PNG image using PyQt6.
- Parameters:
filename (str) – Output PNG file path.
width (int) – Width of the exported image in pixels (default: 1920).
height (int) – Height of the exported image in pixels (default: 1080).
wait_time (float) – Time in seconds to wait for map rendering before capture (default: 1.0).
paper_format (bool) – If True, exports with white background and no map tiles, suitable for papers (default: False).
show_node_ids (bool) – If True, displays node IDs on the map (default: False).
- Raises:
ImportError – If PyQt6 is not installed.
Warning
When using
show_node_ids=True, increasewait_timeto 5.0 seconds or higher to ensure proper rendering of node IDs in the PNG output. Insufficient wait time may result in blank or incomplete renders.
- show_map(mode: str = 'window', show_node_ids: bool = False) None
Display the interactive map in a web browser or GUI window.
Creates an HTML map and displays it either in the system’s default web browser or in an interactive PyQt window.
The map includes: - Interactive nodes with clickable popups showing node information - Links between nodes with hover tooltips - Zoom and pan controls - Fullscreen mode - Distance measurement tool
- Parameters:
mode (str) – Display mode - “window” opens in PyQt window, “browser” opens in web browser (default: “window”).
show_node_ids (bool) – If True, displays node IDs on the map (default: False).
- Raises:
ImportError – If mode=”window” and PyQt6 is not installed.
- Returns:
None