47 lines
939 B
Python
47 lines
939 B
Python
"""
|
|
Node 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 typing import List
|
|
from city_model_structure.attributes.edge import Edge
|
|
|
|
|
|
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
|
|
|
|
@property
|
|
def name(self):
|
|
"""
|
|
Node name
|
|
"""
|
|
return self._name
|
|
|
|
@property
|
|
def id(self):
|
|
"""
|
|
Node 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]:
|
|
"""
|
|
Edges delimited by the node
|
|
"""
|
|
return self._edges
|