forked from s_ranjbar/city_retrofit
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
|
"""
|
||
|
Network module
|
||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||
|
Contributor Milad milad.aghamohamadnia@concordia.ca
|
||
|
"""
|
||
|
import uuid
|
||
|
|
||
|
from city_model_structure.city_object import CityObject
|
||
|
from city_model_structure.attributes.edge import Edge
|
||
|
from city_model_structure.attributes.node import Node
|
||
|
from typing import List
|
||
|
|
||
|
|
||
|
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):
|
||
|
"""
|
||
|
Network id, an universally unique identifier randomly generated
|
||
|
:return: str
|
||
|
"""
|
||
|
if self._id is None:
|
||
|
self._id = uuid.uuid4()
|
||
|
return self._id
|
||
|
|
||
|
@property
|
||
|
def edges(self) -> List[Edge]:
|
||
|
"""
|
||
|
Network edges
|
||
|
"""
|
||
|
return self._edges
|
||
|
|
||
|
@property
|
||
|
def nodes(self) -> List[Node]:
|
||
|
return self._nodes
|