topolib.elements package
Submodules
topolib.elements.link module
- class topolib.elements.link.Link(id: int, source: Node, target: Node, length: float)
Bases:
objectRepresents a link between two nodes.
- Parameters:
id (int) – Unique identifier for the link.
source (
topolib.elements.node.Node) – Source node-like object (must have id, name, latitude, longitude).target (
topolib.elements.node.Node) – Target node-like object (must have id, name, latitude, longitude).length (float) – Length of the link (must be non-negative).
Examples
>>> link = Link(1, nodeA, nodeB, 10.5) >>> link.length
- endpoints()
Return the (source, target) nodes as a tuple.
- Returns:
(source_node, target_node)
- Return type:
tuple
- property id: int
Unique identifier for the link.
- Type:
int
- property length: float
Length of the link (non-negative).
- Type:
float
topolib.elements.node module
Node class for optical network topologies.
This module defines the Node class, representing a network node with geographic coordinates.
- class topolib.elements.node.Node(id: int, name: str, latitude: float, longitude: float, weight: float = 0, pop: int = 0, dc: int = 0, ixp: int = 0)
Bases:
objectRepresents a node in an optical network topology.
- Parameters:
id (int) – Unique identifier for the node.
name (str) – Name of the node.
latitude (float) – Latitude coordinate of the node.
longitude (float) – Longitude coordinate of the node.
weight (float or int) – Node weight (optional, default 0).
pop (int) – Node population (optional, default 0).
dc (int) – Datacenter (DC) value for the node (optional, default 0).
ixp (int) – IXP (Internet Exchange Point) value for the node (optional, default 0).
- coordinates() Tuple[float, float]
Returns the (latitude, longitude) coordinates of the node.
- Returns:
Tuple containing latitude and longitude.
- Return type:
Tuple[float, float]
- property dc: int
Get the datacenter (DC) count or value for the node.
- Returns:
Node DC value.
- Return type:
int
- property id: int
Get the unique identifier of the node.
- Returns:
Node ID.
- Return type:
int
- property ixp: int
Get the IXP (Internet Exchange Point) count or value for the node.
- Returns:
Node IXP value.
- Return type:
int
- property latitude: float
Get the latitude coordinate of the node.
- Returns:
Latitude value.
- Return type:
float
- property longitude: float
Get the longitude coordinate of the node.
- Returns:
Longitude value.
- Return type:
float
- property name: str
Get the name of the node.
- Returns:
Node name.
- Return type:
str
- property pop: int
Get the population of the node.
- Returns:
Node population.
- Return type:
int
- property weight: float
Get the weight of the node.
- Returns:
Node weight.
- Return type:
float