mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-29 17:14:38 +00:00
refactor: Follow the PEP 585 Typing standard (#439)
* Follow the PEP 585 Typing standard * Update list.py
This commit is contained in:
@@ -10,10 +10,10 @@ from modules import *
|
||||
|
||||
class GraphAdjList:
|
||||
""" 基于邻接表实现的无向图类 """
|
||||
def __init__(self, edges: List[List[Vertex]]) -> None:
|
||||
def __init__(self, edges: list[list[Vertex]]) -> None:
|
||||
""" 构造方法 """
|
||||
# 邻接表,key: 顶点,value:该顶点的所有邻接顶点
|
||||
self.adj_list: Dict = {}
|
||||
self.adj_list = dict[Vertex, Vertex]()
|
||||
# 添加所有顶点和边
|
||||
for edge in edges:
|
||||
self.add_vertex(edge[0])
|
||||
|
||||
Reference in New Issue
Block a user