mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-27 00:16:30 +08:00
21 lines
482 B
Python
21 lines
482 B
Python
|
# File: vertex.py
|
||
|
# Created Time: 2023-02-23
|
||
|
# Author: krahets (krahets@163.com)
|
||
|
|
||
|
|
||
|
class Vertex:
|
||
|
"""頂點類別"""
|
||
|
|
||
|
def __init__(self, val: int):
|
||
|
self.val = val
|
||
|
|
||
|
|
||
|
def vals_to_vets(vals: list[int]) -> list["Vertex"]:
|
||
|
"""輸入值串列 vals ,返回頂點串列 vets"""
|
||
|
return [Vertex(val) for val in vals]
|
||
|
|
||
|
|
||
|
def vets_to_vals(vets: list["Vertex"]) -> list[int]:
|
||
|
"""輸入頂點串列 vets ,返回值串列 vals"""
|
||
|
return [vet.val for vet in vets]
|