hello-algo/codes/python/modules/vertex.py

17 lines
489 B
Python
Raw Normal View History

# File: vertex.py
# Created Time: 2023-02-23
# Author: Krahets (krahets@163.com)
class Vertex:
2023-03-03 03:07:22 +08:00
""" 顶点类 """
def __init__(self, val: int) -> None:
self.val = val
def vals_to_vets(vals: list[int]) -> list['Vertex']:
2023-03-03 03:07:22 +08:00
""" 输入值列表 vals ,返回顶点列表 vets """
return [Vertex(val) for val in vals]
def vets_to_vals(vets: list['Vertex']) -> list[int]:
2023-03-03 03:07:22 +08:00
""" 输入顶点列表 vets ,返回值列表 vals """
return [vet.val for vet in vets]