2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
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
|
2021-09-01 09:39:27 -04:00
|
|
|
from typing import List, TypeVar
|
|
|
|
|
|
|
|
UsageZone = TypeVar('Node')
|
2021-08-17 12:52:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
class Edge:
|
|
|
|
"""
|
|
|
|
Generic edge class to be used as base for the network edges
|
|
|
|
"""
|
2021-08-17 13:30:51 -04:00
|
|
|
def __init__(self, name, nodes=None):
|
|
|
|
if nodes is None:
|
|
|
|
nodes = []
|
2021-08-17 12:52:48 -04:00
|
|
|
self._name = name
|
|
|
|
self._id = None
|
|
|
|
self._nodes = nodes
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get edge 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 edge 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 nodes(self) -> List[Node]:
|
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Get delimiting nodes for the edge
|
|
|
|
:return: [Node]
|
2021-08-17 12:52:48 -04:00
|
|
|
"""
|
|
|
|
return self._nodes
|