Created
May 3, 2022 03:19
-
-
Save sausheong/c83cf186f5c6db5cef51c3af8ee76cc0 to your computer and use it in GitHub Desktop.
mst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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