MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / test_vector

Function test_vector

graphs/prim.py:118–146  ·  view source on GitHub ↗

# Creates a list to store x vertices. >>> x = 5 >>> G = [Vertex(n) for n in range(x)] >>> connect(G, 1, 2, 15) >>> connect(G, 1, 3, 12) >>> connect(G, 2, 4, 13) >>> connect(G, 2, 5, 5) >>> connect(G, 3, 2, 6) >>> connect(G, 3, 4, 6) >>> connect(G, 0, 0, 0)

()

Source from the content-addressed store, hash-verified

116
117
118def test_vector() -> None:
119 """
120 # Creates a list to store x vertices.
121 >>> x = 5
122 >>> G = [Vertex(n) for n in range(x)]
123
124 >>> connect(G, 1, 2, 15)
125 >>> connect(G, 1, 3, 12)
126 >>> connect(G, 2, 4, 13)
127 >>> connect(G, 2, 5, 5)
128 >>> connect(G, 3, 2, 6)
129 >>> connect(G, 3, 4, 6)
130 >>> connect(G, 0, 0, 0) # Generate the minimum spanning tree:
131 >>> G_heap = G[:]
132 >>> MST = prim(G, G[0])
133 >>> MST_heap = prim_heap(G, G[0])
134 >>> for i in MST:
135 ... print(i)
136 (2, 3)
137 (3, 1)
138 (4, 3)
139 (5, 2)
140 >>> for i in MST_heap:
141 ... print(i)
142 (2, 3)
143 (3, 1)
144 (4, 3)
145 (5, 2)
146 """
147
148
149if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected