Skip to content

Instantly share code, notes, and snippets.

@sausheong
Created May 3, 2022 04:21
Show Gist options
  • Select an option

  • Save sausheong/6f4be760e0f270a36a91c52bf199e228 to your computer and use it in GitHub Desktop.

Select an option

Save sausheong/6f4be760e0f270a36a91c52bf199e228 to your computer and use it in GitHub Desktop.
mst
func main() {
graph := buildGraph()
fmt.Println("GRAPH\n-----")
nodes := sortNodes(graph.Nodes)
for _, node := range nodes {
fmt.Printf("%s -> %v\n", node.name, graph.Edges[node.name])
}
fmt.Println()
bMST := boruvka(graph)
fmt.Println("BORUVSKA MINIMUM SPANNING TREE\n-----------------------------")
nodes = sortNodes(bMST.Nodes)
for _, node := range nodes {
fmt.Printf("%s -> %v\n", node.name, bMST.Edges[node.name])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment