本文整理汇总了Python中algorithm.Algorithm.constructSpanningTree方法的典型用法代码示例。如果您正苦于以下问题:Python Algorithm.constructSpanningTree方法的具体用法?Python Algorithm.constructSpanningTree怎么用?Python Algorithm.constructSpanningTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类algorithm.Algorithm
的用法示例。
在下文中一共展示了Algorithm.constructSpanningTree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Vertex
# 需要导入模块: from algorithm import Algorithm [as 别名]
# 或者: from algorithm.Algorithm import constructSpanningTree [as 别名]
from vertex import Vertex
from edge import Edge
from algorithm import Algorithm
vertex1 = Vertex("1")
vertex2 = Vertex("2")
vertex3 = Vertex("3")
vertex4 = Vertex("4")
edge1 = Edge(1, vertex1, vertex2)
edge2 = Edge(1, vertex1, vertex3)
edge3 = Edge(0.01, vertex1, vertex4)
edge4 = Edge(1, vertex3, vertex4)
vertex1.adjacencies.append(edge1)
vertex1.adjacencies.append(edge2)
vertex1.adjacencies.append(edge3)
vertex3.adjacencies.append(edge4)
unvisitedList = []
unvisitedList.append(vertex1)
unvisitedList.append(vertex2)
unvisitedList.append(vertex3)
unvisitedList.append(vertex4)
algorithm = Algorithm(unvisitedList)
algorithm.constructSpanningTree(vertex1)
示例2: Edge
# 需要导入模块: from algorithm import Algorithm [as 别名]
# 或者: from algorithm.Algorithm import constructSpanningTree [as 别名]
edge2 = Edge(4, vertex1, vertex4)
edge3 = Edge(4, vertex2, vertex3)
edge4 = Edge(4, vertex2, vertex4)
edge5 = Edge(3, vertex2, vertex5)
edge6 = Edge(1, vertex2, vertex6)
edge7 = Edge(5, vertex3, vertex6)
edge8 = Edge(2, vertex4, vertex5)
edge9 = Edge(5, vertex5, vertex6)
vertexList = []
vertexList.append(vertex1)
vertexList.append(vertex2)
vertexList.append(vertex3)
vertexList.append(vertex4)
vertexList.append(vertex5)
vertexList.append(vertex6)
edgeList = []
edgeList.append(edge1)
edgeList.append(edge2)
edgeList.append(edge3)
edgeList.append(edge4)
edgeList.append(edge5)
edgeList.append(edge6)
edgeList.append(edge7)
edgeList.append(edge8)
edgeList.append(edge9)
algorithm = Algorithm()
algorithm.constructSpanningTree(vertexList, edgeList)