2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
Node 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
|
|
|
"""
|
|
|
|
|
|
|
|
import uuid
|
2021-09-01 09:39:27 -04:00
|
|
|
from typing import List, TypeVar
|
2021-10-22 13:13:12 -04:00
|
|
|
from city_model_structure.attributes.time_series import TimeSeries
|
2021-09-13 15:14:54 -04:00
|
|
|
Edge = TypeVar('Edge')
|
|
|
|
|
2021-08-17 12:52:48 -04:00
|
|
|
|
|
|
|
class Node:
|
|
|
|
"""
|
|
|
|
Generic node class to be used as base for the network nodes
|
|
|
|
"""
|
|
|
|
def __init__(self, name, edges=None):
|
|
|
|
if edges is None:
|
|
|
|
edges = []
|
|
|
|
self._name = name
|
|
|
|
self._id = None
|
|
|
|
self._edges = edges
|
2021-10-22 13:13:12 -04:00
|
|
|
self._time_series = None
|
2021-08-17 12:52:48 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get node name
|
|
|
|
:return: str
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
return self._name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def id(self):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get node id, an 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-10-25 13:33:08 -04:00
|
|
|
Get edges delimited by the node
|
2021-08-30 14:39:24 -04:00
|
|
|
:return: [Edge]
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
return self._edges
|
2021-10-22 13:13:12 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def time_series(self) -> TimeSeries:
|
2021-10-25 13:33:08 -04:00
|
|
|
"""
|
|
|
|
Add explanation here
|
|
|
|
:return: add type of variable here
|
|
|
|
"""
|
2021-10-22 13:13:12 -04:00
|
|
|
return self._time_series
|