53 lines
1.8 KiB
C
53 lines
1.8 KiB
C
#ifndef INCLUDED_C_LAZYPRIMMST_H
|
|||
|
|
#define INCLUDED_C_LAZYPRIMMST_H
|
||
|
|
|
||
|
|
#ifndef INCLUDED_C_EDGEWEIGHTEDGRAPH_H
|
||
|
|
#include <c_EdgeWeightedGraph.h>
|
||
|
|
#endif /*INCLUDED_C_EDGEWEIGHTEDGRAPH_H*/
|
||
|
|
|
||
|
|
|
||
|
|
#ifndef INCLUDED_C_VERTEXIDLIST_H
|
||
|
|
#include <c_VertexIdList.h>
|
||
|
|
#endif /*INCLUDED_C_VERTEXIDLIST_H*/
|
||
|
|
|
||
|
|
|
||
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||
|
|
/* */
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
c_bool_t* marked; /* Visited tracking array (size of graph->V) */
|
||
|
|
c_VertexIdList_t mst_edges; /* List of global edge_ids included in the MST */
|
||
|
|
double weight; /* Total total minimum weight summation of the MST */
|
||
|
|
c_Allocator_t allocator; /* Deep copy of the user-provided allocator */
|
||
|
|
} c_LazyPrimMST_t;
|
||
|
|
|
||
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||
|
|
/* */
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Computes a minimum spanning tree of an edge-weighted graph using Lazy Prim's algorithm.
|
||
|
|
* @param allocator Explicit allocator context used to allocate internal search tracking objects
|
||
|
|
*/
|
||
|
|
c_err_t c_LazyPrimMST_Init(c_LazyPrimMST_t* self, c_EdgeWeightedGraph_t* graph, c_Allocator_t* allocator);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Releases internal tracking buffers
|
||
|
|
*/
|
||
|
|
void c_LazyPrimMST_Destroy(c_LazyPrimMST_t* self);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Gets a copy of the edge ids included in the Minimum Spanning Tree.
|
||
|
|
* @param out_edges An initialized c_VertexIdList_t container to collect the sequence.
|
||
|
|
*/
|
||
|
|
c_err_t c_LazyPrimMST_GetEdges(c_LazyPrimMST_t* self, c_VertexIdList_t* out_edges);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Returns the total total minimum weight summation of the MST
|
||
|
|
*/
|
||
|
|
C_STATIC_FORCE_INLINE
|
||
|
|
double c_LazyPrimMST_Weight(c_LazyPrimMST_t* self) {
|
||
|
|
return self ? self->weight : 0.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif /*INCLUDED_C_LAZYPRIMMST_H*/
|