Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from heapq import heappush
- from heapq import heappop
- # Heappop returns the element of the heap with the minimum value
- def prim(edges):
- return 1
- def visualize(edges):
- from pyvis.network import Network
- G = Network()
- for u, v, weight in edges:
- G.add_node(u)
- G.add_node(v)
- G.add_edge(u, v, label=str(weight))
- G.show("network.html")
- edges = [('A', 'B', 2), ('A', 'C', 3), ('A', 'D', 3), ('B', 'C', 4),
- ('B', 'E', 3), ('C', 'D', 5), ('C', 'E', 1), ('C', 'F', 6),
- ('D', 'F', 7), ('E', 'F', 8), ('F', 'G', 9)]
- visualize(edges)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement