hello-algo/codes
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
..
c Bug fixes and improvements (#1380) 2024-05-31 16:39:06 +08:00
cpp [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
csharp [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
dart [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
go fix(Go): code comment error (#1404) 2024-06-28 19:18:17 +08:00
java [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
javascript [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
kotlin Bug fixes and improvements (#1380) 2024-05-31 16:39:06 +08:00
python Update graph_adjacency_matrix.py 2024-07-26 21:26:57 +08:00
pythontutor Several bug fixes and improvements (#1178) 2024-03-26 02:49:26 +08:00
ruby Bug fixes and improvements (#1380) 2024-05-31 16:39:06 +08:00
rust remove unnecessary type conversions (#1411) 2024-07-14 18:36:00 +08:00
swift [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
typescript [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
zig [Rust] Normalize mid calculation in case overflow (#1363) 2024-05-18 18:19:19 +08:00
docker-compose.yml Several bug fixes and improvements (#945) 2023-11-14 21:27:35 +08:00
Dockerfile feat(csharp) .NET 8.0 code migration (#966) 2023-11-26 23:18:44 +08:00