mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 00:26:29 +08:00
fix: removeEdge not effects on graph in golang (#503)
* fix(graph/adjacency_list):removeEdge not effects on graph in golang * remove unecessary package right now * Delete go.sum --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
parent
200275b39a
commit
763955aa8b
1 changed files with 4 additions and 4 deletions
|
@ -57,8 +57,8 @@ func (g *graphAdjList) removeEdge(vet1 Vertex, vet2 Vertex) {
|
|||
panic("error")
|
||||
}
|
||||
// 删除边 vet1 - vet2
|
||||
DeleteSliceElms(g.adjList[vet1], vet2)
|
||||
DeleteSliceElms(g.adjList[vet2], vet1)
|
||||
g.adjList[vet1] = DeleteSliceElms(g.adjList[vet1], vet2)
|
||||
g.adjList[vet2] = DeleteSliceElms(g.adjList[vet2], vet1)
|
||||
}
|
||||
|
||||
/* 添加顶点 */
|
||||
|
@ -80,8 +80,8 @@ func (g *graphAdjList) removeVertex(vet Vertex) {
|
|||
// 在邻接表中删除顶点 vet 对应的链表
|
||||
delete(g.adjList, vet)
|
||||
// 遍历其他顶点的链表,删除所有包含 vet 的边
|
||||
for _, list := range g.adjList {
|
||||
DeleteSliceElms(list, vet)
|
||||
for v, list := range g.adjList {
|
||||
g.adjList[v] = DeleteSliceElms(list, vet)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue