本文整理匯總了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)