hello-algo/codes/python
Fuuuuuji 95214b144c
Update graph_adjacency_matrix.py
理解K神这个实现主要是为了演示邻接矩阵的基本原理,但在实际使用中可能会遇到一些限制:在实际应用中,通常使用顶点的值而不是索引来操作图。所以,为了更“公平”地与邻接表方法的对比,进行了改进:
1. 引入 vertex_map:使用字典 vertex_map 来存储顶点值到索引的映射。
2. 基于值的操作:add_vertex, remove_vertex, add_edge, 和 remove_edge 方法现在都使用顶点值而不是索引。这使得图的操作更加直观和用户友好。
3. 动态索引管理:在 remove_vertex 方法中,更新了剩余顶点的索引映射。这确保了在删除顶点后,其他顶点的索引仍然保持正确。
2024-07-26 21:26:57 +08:00
..
chapter_array_and_linkedlist Some improvements (#1073) 2024-02-07 22:21:18 +08:00
chapter_backtracking Some improvements (#1073) 2024-02-07 22:21:18 +08:00
chapter_computational_complexity Bug fixes and improvements (#1380) 2024-05-31 16:39:06 +08:00
chapter_divide_and_conquer Some improvements (#1073) 2024-02-07 22:21:18 +08:00
chapter_dynamic_programming Some improvements (#1073) 2024-02-07 22:21:18 +08:00
chapter_graph Update graph_adjacency_matrix.py 2024-07-26 21:26:57 +08:00
chapter_greedy Some improvements (#1073) 2024-02-07 22:21:18 +08:00
chapter_hashing Some improvements (#1073) 2024-02-07 22:21:18 +08:00
chapter_heap Some improvements (#1073) 2024-02-07 22:21:18 +08:00
chapter_searching Some improvements (#1073) 2024-02-07 22:21:18 +08:00
chapter_sorting [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
chapter_stack_and_queue Bug fixes and improvements (#1298) 2024-04-22 02:26:32 +08:00
chapter_tree Bug fixes and improvements (#1318) 2024-04-30 15:52:05 +08:00
modules Fix bugs and harmonize the code comments (#1199) 2024-03-31 03:06:41 +08:00
.gitignore Format the Java codes with the Reat Hat extension. 2023-04-14 00:12:10 +08:00
test_all.py feature: add auto-build-and-test workflow for go (#1019) 2024-01-12 14:17:21 +08:00