2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
Network module
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
2021-10-22 13:13:12 -04:00
|
|
|
|
2021-08-17 12:52:48 -04:00
|
|
|
import uuid
|
2021-08-26 09:19:38 -04:00
|
|
|
from typing import List
|
2021-08-17 12:52:48 -04:00
|
|
|
|
|
|
|
from city_model_structure.city_object import CityObject
|
|
|
|
from city_model_structure.attributes.edge import Edge
|
|
|
|
from city_model_structure.attributes.node import Node
|
|
|
|
|
|
|
|
|
|
|
|
class Network(CityObject):
|
|
|
|
"""
|
|
|
|
Generic network class to be used as base for the network models
|
|
|
|
"""
|
|
|
|
def __init__(self, name, edges=None, nodes=None):
|
|
|
|
super().__init__(name, 0, [], None)
|
|
|
|
if nodes is None:
|
|
|
|
nodes = []
|
|
|
|
if edges is None:
|
|
|
|
edges = []
|
|
|
|
self._id = None
|
|
|
|
self._edges = edges
|
|
|
|
self._nodes = nodes
|
|
|
|
|
|
|
|
@property
|
|
|
|
def id(self):
|
|
|
|
"""
|
2022-05-16 10:19:03 -04:00
|
|
|
Get network id, a universally unique identifier randomly generated
|
2021-08-17 12:52:48 -04:00
|
|
|
:return: str
|
|
|
|
"""
|
|
|
|
if self._id is None:
|
|
|
|
self._id = uuid.uuid4()
|
|
|
|
return self._id
|
|
|
|
|
|
|
|
@property
|
|
|
|
def edges(self) -> List[Edge]:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get network edges
|
|
|
|
:return: [Edge]
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
return self._edges
|
|
|
|
|
|
|
|
@property
|
|
|
|
def nodes(self) -> List[Node]:
|
2021-08-26 09:19:38 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get network nodes
|
|
|
|
:return: [Node]
|
2021-08-26 09:19:38 -04:00
|
|
|
"""
|
2021-08-17 12:52:48 -04:00
|
|
|
return self._nodes
|