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>
pull/580/head
Jerry You 1 year ago committed by GitHub
parent 200275b39a
commit 763955aa8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -57,8 +57,8 @@ func (g *graphAdjList) removeEdge(vet1 Vertex, vet2 Vertex) {
panic("error") panic("error")
} }
// 删除边 vet1 - vet2 // 删除边 vet1 - vet2
DeleteSliceElms(g.adjList[vet1], vet2) g.adjList[vet1] = DeleteSliceElms(g.adjList[vet1], vet2)
DeleteSliceElms(g.adjList[vet2], vet1) g.adjList[vet2] = DeleteSliceElms(g.adjList[vet2], vet1)
} }
/* 添加顶点 */ /* 添加顶点 */
@ -80,8 +80,8 @@ func (g *graphAdjList) removeVertex(vet Vertex) {
// 在邻接表中删除顶点 vet 对应的链表 // 在邻接表中删除顶点 vet 对应的链表
delete(g.adjList, vet) delete(g.adjList, vet)
// 遍历其他顶点的链表,删除所有包含 vet 的边 // 遍历其他顶点的链表,删除所有包含 vet 的边
for _, list := range g.adjList { for v, list := range g.adjList {
DeleteSliceElms(list, vet) g.adjList[v] = DeleteSliceElms(list, vet)
} }
} }

Loading…
Cancel
Save