Hello 算法 1.0.0b2 Python版堆化操作用于修复堆的特性,在入堆和出堆操作中都会使用到。 ‧ 输入 ? 个元素并建堆的时间复杂度可以被优化至 ?(?) ,非常高效。 127 9. 图 9.1. 图 「图 Graph」是一种非线性数据结构,由「顶点 Vertex」和「边 Edge」组成。我们可将图 ? 抽象地表示为一 组顶点 ? 和一组边 ? 的集合。例如,以下表示一个包含 5 个顶点和 7 条边的图 ? = {1, 2, 3, 4, 5} ? = self.add_vertex(val) # 添加边 # 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 for e in edges: self.add_edge(e[0], e[1]) def size(self) -> int: """ 获取顶点数量 """ return len(self.vertices) def add_vertex(self, val: self.adj_mat.append(new_row) # 在邻接矩阵中添加一列 for row in self.adj_mat: row.append(0) def remove_vertex(self, index: int) -> None: """ 删除顶点 """ if index >= self.size(): raise IndexError() # 在顶点列表中移除索引0 码力 | 186 页 | 15.69 MB | 1 年前3
Hello 算法 1.0.0b1 Python版堆化操作用于修复堆的特性,在入堆和出堆操作中都会使用到。 ‧ 输入 ? 个元素并建堆的时间复杂度可以被优化至 ?(?) ,非常高效。 126 9. 图 9.1. 图 「图 Graph」是一种非线性数据结构,由「顶点 Vertex」和「边 Edge」组成。我们可将图 ? 抽象地表示为一 组顶点 ? 和一组边 ? 的集合。例如,以下表示一个包含 5 个顶点和 7 条边的图 ? = {1, 2, 3, 4, 5} ? = vertices: self.add_vertex(val) # 添加边 # 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 for e in edges: self.add_edge(e[0], e[1]) def size(self): """ 获取顶点数量 """ return len(self.vertices) def add_vertex(self, val): self.adj_mat.append(new_row) # 在邻接矩阵中添加一列 for row in self.adj_mat: row.append(0) def remove_vertex(self, index): """ 删除顶点 """ if index >= self.size(): raise IndexError() # 在顶点列表中移除索引 index 的顶点0 码力 | 178 页 | 14.67 MB | 1 年前3
Hello 算法 1.0.0b4 Python版存泄露。相较于栈内 存,堆内存的管理和使用需要更谨慎,不恰当的使用可能会导致内存泄露和野指针等问题。 155 9. 图 9.1. 图 「图 Graph」是一种非线性数据结构,由「顶点 Vertex」和「边 Edge」组成。我们可以将图 ? 抽象地表示 为一组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} self.add_vertex(val) # 添加边 # 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 for e in edges: self.add_edge(e[0], e[1]) def size(self) -> int: """ 获取顶点数量""" return len(self.vertices) def add_vertex(self, val: self.adj_mat.append(new_row) # 在邻接矩阵中添加一列 for row in self.adj_mat: row.append(0) def remove_vertex(self, index: int): """ 删除顶点""" if index >= self.size(): raise IndexError() # 在顶点列表中移除索引 index0 码力 | 329 页 | 27.34 MB | 1 年前3
Hello 算法 1.1.0 Python版见的边相连。 每一次的相识与相离,都在这张巨大的网络图中留下独特的印记。 第 9 章 图 hello‑algo.com 179 9.1 图 图(graph)是一种非线性数据结构,由顶点(vertex)和边(edge)组成。我们可以将图 ? 抽象地表示为一 组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} ? self.add_vertex(val) # 添加边 # 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 for e in edges: self.add_edge(e[0], e[1]) def size(self) -> int: """ 获取顶点数量""" return len(self.vertices) def add_vertex(self, val: self.adj_mat.append(new_row) # 在邻接矩阵中添加一列 for row in self.adj_mat: row.append(0) def remove_vertex(self, index: int): """ 删除顶点""" if index >= self.size(): raise IndexError() # 在顶点列表中移除索引 index0 码力 | 364 页 | 18.42 MB | 1 年前3
Hello 算法 1.0.0 Python版边相连。 每一次的相识与相离,都在这张巨大的网络图中留下独特的印记。 第 9 章 图 hello‑algo.com 179 9.1 图 「图 graph」是一种非线性数据结构,由「顶点 vertex」和「边 edge」组成。我们可以将图 ? 抽象地表示为 一组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} # 邻接矩阵,行列索引对应“顶点索引” self.adj_mat: list[list[int]] = [] # 添加顶点 for val in vertices: self.add_vertex(val) 第 9 章 图 hello‑algo.com 185 # 添加边 # 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 for e in edges: self.add_edge(e[0], e[1]) def size(self) -> int: """ 获取顶点数量""" return len(self.vertices) def add_vertex(self, val: int): """ 添加顶点""" n = self.size() # 向顶点列表中添加新顶点的值 self.vertices.append(val) # 在邻接矩阵中添加一行0 码力 | 362 页 | 17.54 MB | 1 年前3
Hello 算法 1.0.0b5 Python版边相连。 每一次的相识与相离,都在这张巨大的网络图中留下独特的印记。 第 9 章 图 hello‑algo.com 176 9.1 图 「图 graph」是一种非线性数据结构,由「顶点 vertex」和「边 edge」组成。我们可以将图 ? 抽象地表示为 一组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} self.add_vertex(val) # 添加边 # 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 for e in edges: self.add_edge(e[0], e[1]) def size(self) -> int: """ 获取顶点数量""" return len(self.vertices) def add_vertex(self, val: self.adj_mat.append(new_row) # 在邻接矩阵中添加一列 for row in self.adj_mat: row.append(0) def remove_vertex(self, index: int): """ 删除顶点""" if index >= self.size(): raise IndexError() # 在顶点列表中移除索引 index0 码力 | 361 页 | 30.64 MB | 1 年前3
Hello 算法 1.2.0 简体中文 Python 版连。 每一次的相识与相离,都在这张巨大的网络图中留下独特的印记。 第 9 章 图 www.hello‑algo.com 179 9.1 图 图(graph)是一种非线性数据结构,由顶点(vertex)和边(edge)组成。我们可以将图 ? 抽象地表示为一 组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} ? self.add_vertex(val) # 添加边 # 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 for e in edges: self.add_edge(e[0], e[1]) def size(self) -> int: """ 获取顶点数量""" return len(self.vertices) def add_vertex(self, val: self.adj_mat.append(new_row) # 在邻接矩阵中添加一列 for row in self.adj_mat: row.append(0) def remove_vertex(self, index: int): """ 删除顶点""" if index >= self.size(): raise IndexError() # 在顶点列表中移除索引 index0 码力 | 364 页 | 18.43 MB | 10 月前3
Hello 算法 1.2.0 繁体中文 Python 版連。 每一次的相識與相離,都在這張巨大的網路圖中留下獨特的印記。 第 9 章 圖 www.hello‑algo.com 179 9.1 圖 圖(graph)是一種非線性資料結構,由頂點(vertex)和邊(edge)組成。我們可以將圖 ? 抽象地表示為一 組頂點 ? 和一組邊 ? 的集合。以下示例展示了一個包含 5 個頂點和 7 條邊的圖。 ? = {1, 2, 3, 4, 5} ? self.add_vertex(val) # 新增邊 # 請注意,edges 元素代表頂點索引,即對應 vertices 元素索引 for e in edges: self.add_edge(e[0], e[1]) def size(self) -> int: """ 獲取頂點數量""" return len(self.vertices) def add_vertex(self, val: # 在鄰接矩陣中新增一列 for row in self.adj_mat: 第 9 章 圖 www.hello‑algo.com 185 row.append(0) def remove_vertex(self, index: int): """ 刪除頂點""" if index >= self.size(): raise IndexError() # 在頂點串列中移除索引 index0 码力 | 364 页 | 18.74 MB | 10 月前3
MuPDF 1.22.0 Documentation21.2 addInkListStrokeVertex(vertex) Append a vertex to end of the last stroke in the ink annotation. The vertex is an array of its X/Y coordinates. Arguments • vertex – []. Text markup and redaction command line MuPDF Documentation, Release 1.21.2 addVertex(vertex) Append a single vertex as an array of its X/Y coordinates. Arguments • vertex – []. Stamp annotations have the option to set a custom0 码力 | 175 页 | 698.87 KB | 8 月前3
MuPDF 1.23.0 DocumentationaddInkListStroke(); addInkListStrokeVertex(vertex) Append a vertex to end of the last stroke in the ink annotation. The vertex is an array of its X/Y coordinates. Arguments • vertex – [...]. annotation.addInkListStrokeVertex([0 the annotation. annotation.clearVertices(); addVertex(vertex) Append a single vertex as an array of its X/Y coordinates. Arguments • vertex – [...]. annotation.addVertex([0,0]); applyRedaction(blackBoxes0 码力 | 245 页 | 817.74 KB | 8 月前3
共 75 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8













