kosmos.topology.net¶
Classes¶
- class Network¶
Network that stores nodes and links.
Methods
- add_node(node: kosmos.topology.node.Node) None¶
Add a node to the network.
- Parameters:
node (Node) – Node instance to insert.
- add_link(link: kosmos.topology.link.Link) None¶
Add a link to the network.
Both endpoints of the link must be present in the network.
- Parameters:
link (Link) – Link instance to insert.
- get_node(node_id: kosmos.topology.node.NodeId | str) kosmos.topology.node.Node | None¶
Node by id.
- get_link(link_id: kosmos.topology.link.LinkId | str) kosmos.topology.link.Link | None¶
Link by id.
- nodes() collections.abc.Iterable[kosmos.topology.node.Node]¶
Iterate over all nodes.
- Returns:
Iterator over nodes.
- Return type:
Iterable[Node]
- links() collections.abc.Iterable[kosmos.topology.link.Link]¶
Iterate over all links.
- Returns:
Iterator over links.
- Return type:
Iterable[Link]
- outgoing_links(node: kosmos.topology.typing.NodeReference) collections.abc.Iterable[kosmos.topology.link.Link]¶
Outgoing links of a node.
- Parameters:
node (NodeReference) – The node or its id.
- Returns:
Outgoing links of the node.
- Return type:
Iterable[Link]
- incoming_links(node: kosmos.topology.typing.NodeReference) collections.abc.Iterable[kosmos.topology.link.Link]¶
Incoming links of a node.
- Parameters:
node (NodeReference) – The node or its id.
- Returns:
Incoming links of the node.
- Return type:
Iterable[Link]
- validate_node(node: kosmos.topology.typing.NodeReference) kosmos.topology.node.Node¶
Get the node for a node reference if it is valid, else raise.
- Parameters:
node (NodeReference) – The node or its id.
- Returns:
The valid node.
- Return type:
- validate_link(link: kosmos.topology.typing.LinkReference) kosmos.topology.link.Link¶
Get the link for a link reference if it is valid, else raise.
- Parameters:
link (LinkReference) – The link or its id.
- Returns:
The valid link.
- Return type: