Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

文本勘误【数据结构-图】 #22

Open
@Shalomw

Description

  1. 感觉示例代码用的是邻接表法?文本写的是邻接矩阵
// 添加顶点
addVertex(val) {
 // 添加点
 this.vertexes.push(val)
 // 添加点的关系 采用邻接矩阵法 结构用 Map
 this.adjList.set(val, [])
}
// 添加边
addEdge(val1, val2) {
 // 添加边需要传入两个顶点,因为边是两个顶点之间的边,边不可能单独存在。
 // 这里实现的是无向图,所以这里不考虑方向问题
 this.adjList.get(val1).push(val2)
 this.adjList.get(val2).push(val1)
}
  1. 代码里写的是 new Dictionary() ,但字典那章写的是 class Map ,感觉可以统一一下
class Graph {
 constructor() {
 this.vertexes = []; // 存储顶点
 this.adjList = new Dictionay(); //存储边信息
 }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /