This commit is contained in:
krahets
2024-04-11 01:11:20 +08:00
parent a6adc8e20a
commit 739f8a31bb
85 changed files with 1555 additions and 979 deletions

View File

@ -1066,10 +1066,10 @@ comments: true
}
/* 添加顶点 */
fun addVertex(value: Int) {
fun addVertex(_val: Int) {
val n = size()
// 向顶点列表中添加新顶点的值
vertices.add(value)
vertices.add(_val)
// 在邻接矩阵中添加一行
val newRow = mutableListOf<Int>()
for (j in 0..<n) {
@ -2222,9 +2222,9 @@ comments: true
for (pair in adjList.entries) {
val tmp = mutableListOf<Int>()
for (vertex in pair.value) {
tmp.add(vertex.value)
tmp.add(vertex._val)
}
println("${pair.key.value}: $tmp,")
println("${pair.key._val}: $tmp,")
}
}
}