我正在尝试制作一个邻接列表,但我需要源和目的地的边缘:
class Vertex:
def __init__(self, node):
self.id = node
self.next = None
class Graph:
def __init__(self, verticies):
self.nV = verticies
self.graph_arr = [None]*self.nV
def add_edges(self, source, destination):
node = Vertex(destination)
node.next = self.graph_arr[source]
我有50多个垂直领域,所以我不能只手动插入它们+我需要能够承受变化的代码。
我不知道从哪里开始,
任何建议都将不胜感激。