summer_course_2024/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 © 2021 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
2021-08-17 12:52:48 -04:00
Contributor Milad milad.aghamohamadnia@concordia.ca
"""
2021-08-17 12:52:48 -04:00
import uuid
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):
"""
Get network 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]:
"""
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