Skip to content

Instantly share code, notes, and snippets.

@sausheong
Created May 3, 2022 03:19
Show Gist options
  • Save sausheong/c83cf186f5c6db5cef51c3af8ee76cc0 to your computer and use it in GitHub Desktop.
Save sausheong/c83cf186f5c6db5cef51c3af8ee76cc0 to your computer and use it in GitHub Desktop.
mst
func (g *Graph) RemoveEdge(n1, n2 string) {
rmEdge(g, n1, n2)
rmEdge(g, n2, n1)
}
func rmEdge(g *Graph, m, n string) {
edges := g.Edges[m]
r := -1
for i, edge := range edges {
if edge.node.name == n {
r = i
}
}
if r > -1 {
edges[r] = edges[len(edges)-1]
g.Edges[m] = edges[:len(edges)-1]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment