city_retrofit/hub/city_model_structure/network.py

55 lines
1.2 KiB
Python
Raw Normal View History

2021-08-17 12:52:48 -04:00
"""
Network module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
2021-08-17 12:52:48 -04:00
"""
2021-08-17 12:52:48 -04:00
import uuid
from typing import List
2021-08-17 12:52:48 -04:00
2023-01-24 10:51:50 -05:00
from hub.city_model_structure.city_object import CityObject
from hub.city_model_structure.attributes.edge import Edge
from hub.city_model_structure.attributes.node import Node
2021-08-17 12:52:48 -04:00
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):
"""
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]:
"""
Get network edges
:return: [Edge]
2021-08-17 12:52:48 -04:00
"""
return self._edges
@property
def nodes(self) -> List[Node]:
"""
Get network nodes
:return: [Node]
"""
2021-08-17 12:52:48 -04:00
return self._nodes