# -*- coding: utf-8 -*-
# @Time : 2023/8/4 16:20
# @Author : Ultipa
# @Email : [email protected]
# @File : Path.py
from typing import Dict, List
from ultipa.structs.Schema import Schema
from ultipa.structs.BaseModel import BaseModel
from ultipa.structs.Edge import Edge
from ultipa.structs.Node import Node
[docs]
class Path(BaseModel):
'''
Data class for path.
'''
nodeSchemas: Dict[str, Schema] = {}
edgeSchemas: Dict[str, Schema] = {}
def __init__(self, nodes: List[Node], edges: List[Edge], nodeSchemas, edgeSchemas):
self.nodes = nodes
self.edges = edges
self.nodeSchemas = nodeSchemas
self.edgeSchemas = edgeSchemas
[docs]
def length(self):
return len(self.edges)
[docs]
def getNodes(self):
return self.nodes
[docs]
def getEdges(self):
return self.edges
[docs]
class PathAlias:
'''
Data class for path with alias.
'''
def __init__(self, alias: str, paths: List[Path] = None):
self.alias = alias
if paths is None:
paths = []
self.paths = paths
[docs]
def length(self):
return len(self.paths)
[docs]
def getNodes(self):
nodes = [i.nodes for i in self.paths]
return nodes
[docs]
def getEdges(self):
edges = [i.edges for i in self.paths]
return edges