|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Prim's algorithm for minimum spanning trees. More...
#include <tpl_agraph.H>#include <tpl_graph_utils.H>#include <archeap.H>#include <ah-errors.H>#include <cookie_guard.H>Go to the source code of this file.
Classes | |
| struct | Aleph::Prim_Info< GT > |
| struct | Aleph::Prim_Heap_Info< GT, Distance > |
| struct | Aleph::Simple_Prim_Heap< GT, Distance > |
| struct | Aleph::Init_Prim_Info< GT > |
| struct | Aleph::Uninit_Prim_Info< GT > |
| class | Aleph::Prim_Min_Spanning_Tree< GT, Distance, SA > |
| Calcula el árbol abarcador mínimo de un grafo según el algoritmo de Prim. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Macros | |
| #define | PRIMINFO(p) static_cast<Prim_Info<GT>*>(NODE_COOKIE(p)) |
| #define | TREENODE(p) (PRIMINFO(p)->tree_node) |
| #define | HEAPNODE(p) (PRIMINFO(p)->heap_node) |
Prim's algorithm for minimum spanning trees.
This file implements Prim's algorithm for finding the Minimum Spanning Tree (MST) of a connected, undirected, weighted graph. The algorithm grows the MST one vertex at a time, always adding the minimum-weight edge that connects a vertex in the tree to a vertex outside.
| Implementation | Time | Space |
|---|---|---|
| Binary Heap | O(E log V) | O(V) |
| Aspect | Prim | Kruskal |
|---|---|---|
| Best for | Dense graphs | Sparse graphs |
| Data structure | Priority queue | Union-Find |
| Edge processing | One at a time | All sorted first |
Definition in file Prim.H.
| #define PRIMINFO | ( | p | ) | static_cast<Prim_Info<GT>*>(NODE_COOKIE(p)) |