Cache-Friendly Design in Robot Path Planningsource, target): for each vertex v in Graph.Vertices: prev[v] ← UNDEFINED # predecessors of v (visited set) create (vertex, vertex, dist) priority queue Q start, 0)) # add start vertex to priority queue while Q is not empty: (p,u,dist_u) ← Q.extract_min() # remove next best vertex (u) and its predecessor of (u) if u is target: # end if we are at the target vertex break for each neighbor v of u with prev[v] is UNDEFINED: dist_v ← dist_u + Graph0 码力 | 216 页 | 10.68 MB | 6 月前3
generic graph librariesgraph from starting vertex S 。Find all vertices reachable on an edge from s (level 1) *。Find all unvisited vertices reachable on an edge from those while (! done) { = visited vertex { for v in neighbors(u) visit Adjacency-List Algorit BFS(G, 9) hms Enumerate vertices 1 for each vertex ET(G) “Vertex 2 color[u] 二 WHITE - ww 3 color[sl bfs(conat Grapht graph,vertex_id_tsource) { sing vertex_id_type = vertex_id_t ; Enumerate atd: :vector color(size(graph)) -一 Vertices for (vertex_id_type u = 0i u < size(graph); 0 码力 | 76 页 | 6.59 MB | 6 月前3
Google 《Prompt Engineering v7》basically write prompts, however this whitepaper focuses on writing prompts for the Gemini model within Vertex AI or by using the API, because by prompting the model directly you will have access to the configuration to be optimized for your specific model, regardless of whether you use Gemini language models in Vertex AI, GPT, Claude, or an open source model like Gemma or LLaMA. Besides the prompt, you will also need the different sampling settings together. If temperature, top-K, and top-P are all available (as in Vertex Studio), tokens that meet both the top-K and top-P criteria are candidates for the next predicted0 码力 | 68 页 | 6.50 MB | 6 月前3
Hello 算法 1.2.0 简体中文 C语言 版连。 每一次的相识与相离,都在这张巨大的网络图中留下独特的印记。 第 9 章 图 www.hello‑algo.com 193 9.1 图 图(graph)是一种非线性数据结构,由顶点(vertex)和边(edge)组成。我们可以将图 ? 抽象地表示为一 组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} ? 为顶点实例,value 为该顶点的邻接顶点列表(链表)。 另外,我们在邻接表中使用 Vertex 类来表示顶点,这样做的原因是:如果与邻接矩阵一样,用列表索引来区 分不同顶点,那么假设要删除索引为 ? 的顶点,则需遍历整个邻接表,将所有大于 ? 的索引全部减 1 ,效率 很低。而如果每个顶点都是唯一的 Vertex 实例,删除某一顶点之后就无须改动其他顶点了。 // === File: graph_adjacency_list typedef struct AdjListNode { Vertex *vertex; // 顶点 struct AdjListNode *next; // 后继节点 } AdjListNode; /* 查找顶点对应的节点 */ AdjListNode *findNode(GraphAdjList *graph, Vertex *vet) { for (int i = 0; i < graph->size;0 码力 | 392 页 | 18.52 MB | 10 月前3
Hello 算法 1.2.0 繁体中文 C语言 版連。 每一次的相識與相離,都在這張巨大的網路圖中留下獨特的印記。 第 9 章 圖 www.hello‑algo.com 193 9.1 圖 圖(graph)是一種非線性資料結構,由頂點(vertex)和邊(edge)組成。我們可以將圖 ? 抽象地表示為一 組頂點 ? 和一組邊 ? 的集合。以下示例展示了一個包含 5 個頂點和 7 條邊的圖。 ? = {1, 2, 3, 4, 5} ? 為頂點例項,value 為該頂點的鄰接頂點串列(鏈結串列)。 另外,我們在鄰接表中使用 Vertex 類別來表示頂點,這樣做的原因是:如果與鄰接矩陣一樣,用串列索引來 區分不同頂點,那麼假設要刪除索引為 ? 的頂點,則需走訪整個鄰接表,將所有大於 ? 的索引全部減 1 ,效 率很低。而如果每個頂點都是唯一的 Vertex 例項,刪除某一頂點之後就無須改動其他頂點了。 // === File: graph_adjacency_list typedef struct AdjListNode { Vertex *vertex; // 頂點 struct AdjListNode *next; // 後繼節點 } AdjListNode; /* 查詢頂點對應的節點 */ AdjListNode *findNode(GraphAdjList *graph, Vertex *vet) { for (int i = 0; i < graph->size;0 码力 | 392 页 | 18.83 MB | 10 月前3
Hello 算法 1.2.0 简体中文 C# 版连。 每一次的相识与相离,都在这张巨大的网络图中留下独特的印记。 第 9 章 图 www.hello‑algo.com 187 9.1 图 图(graph)是一种非线性数据结构,由顶点(vertex)和边(edge)组成。我们可以将图 ? 抽象地表示为一 组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} ? 章 图 www.hello‑algo.com 195 另外,我们在邻接表中使用 Vertex 类来表示顶点,这样做的原因是:如果与邻接矩阵一样,用列表索引来区 分不同顶点,那么假设要删除索引为 ? 的顶点,则需遍历整个邻接表,将所有大于 ? 的索引全部减 1 ,效率 很低。而如果每个顶点都是唯一的 Vertex 实例,删除某一顶点之后就无须改动其他顶点了。 // === File: graph_adjacency_list 邻接表,key:顶点,value:该顶点的所有邻接顶点 public Dictionary<Vertex, List<Vertex>> adjList; /* 构造函数 */ public GraphAdjList(Vertex[][] edges) { adjList = []; // 添加所有顶点和边 foreach (Vertex[] edge in edges) { AddVertex(edge[0]);0 码力 | 379 页 | 18.48 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: 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 简体中文 Java 版连。 每一次的相识与相离,都在这张巨大的网络图中留下独特的印记。 第 9 章 图 www.hello‑algo.com 187 9.1 图 图(graph)是一种非线性数据结构,由顶点(vertex)和边(edge)组成。我们可以将图 ? 抽象地表示为一 组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} ? 章 图 www.hello‑algo.com 195 另外,我们在邻接表中使用 Vertex 类来表示顶点,这样做的原因是:如果与邻接矩阵一样,用列表索引来区 分不同顶点,那么假设要删除索引为 ? 的顶点,则需遍历整个邻接表,将所有大于 ? 的索引全部减 1 ,效率 很低。而如果每个顶点都是唯一的 Vertex 实例,删除某一顶点之后就无须改动其他顶点了。 // === File: graph_adjacency_list 邻接表,key:顶点,value:该顶点的所有邻接顶点 Map<Vertex, List<Vertex>> adjList; /* 构造方法 */ public GraphAdjList(Vertex[][] edges) { this.adjList = new HashMap<>(); // 添加所有顶点和边 for (Vertex[] edge : edges) { addVertex(edge[0]);0 码力 | 379 页 | 18.48 MB | 10 月前3
Hello 算法 1.2.0 简体中文 Dart 版连。 每一次的相识与相离,都在这张巨大的网络图中留下独特的印记。 第 9 章 图 www.hello‑algo.com 187 9.1 图 图(graph)是一种非线性数据结构,由顶点(vertex)和边(edge)组成。我们可以将图 ? 抽象地表示为一 组顶点 ? 和一组边 ? 的集合。以下示例展示了一个包含 5 个顶点和 7 条边的图。 ? = {1, 2, 3, 4, 5} ? 为顶点实例,value 为该顶点的邻接顶点列表(链表)。 另外,我们在邻接表中使用 Vertex 类来表示顶点,这样做的原因是:如果与邻接矩阵一样,用列表索引来区 分不同顶点,那么假设要删除索引为 ? 的顶点,则需遍历整个邻接表,将所有大于 ? 的索引全部减 1 ,效率 很低。而如果每个顶点都是唯一的 Vertex 实例,删除某一顶点之后就无须改动其他顶点了。 第 9 章 图 www.hello‑algo GraphAdjList { // 邻接表,key:顶点,value:该顶点的所有邻接顶点 Map<Vertex, List<Vertex>> adjList = {}; /* 构造方法 */ GraphAdjList(List- Vertex>> edges) { for (List<Vertex> edge in edges) { addVertex(edge[0]); addVertex(edge[1]);
0 码力 | 378 页 | 18.46 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
共 39 条
- 1
- 2
- 3
- 4













