在图的邻接表存储结构下(基于顶点列表和单链表实现),本题要求图类里实现2个方法函数 def addVertex(self, vex_val): def addEdge(self, f, t, cost=0):
函数接口定义:
在这里描述函数接口。例如:
def addVertex(self, vex_val):def addEdge(self, f, t, cost=0):
在这里解释接口参数。例如:其中 f和t分别是构成边的顶点在列表中的序号。
裁判测试程序样例:
在这里给出函数被调用进行测试的例子。例如:
class arcnode:def __init__(self,adjvex,weight,link=None):self.adjvex = adjvexself.weight = weightself.link=linkclass vexnode:def __init__(self,data,first_arc=None):self.data = dataself.first_arc = first_arcclass Graph:def __init__(self):self.vex_list=[]self.vex_num=0self.edge_num=0# 请在这里填写答案# 请在这里填写答案def print_graph(self):for i in rang