Files
cKit/Graph/c_BoruvkaMST.h
T

52 lines
1.6 KiB
C
Raw Normal View History

2026-09-07 18:48:16 +08:00
#ifndef INCLUDED_C_BORUVKAMST_H
#define INCLUDED_C_BORUVKAMST_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_VertexIdList_t mst_edges; /* Final optimized list of edge_ids inside the tree */
double weight; /* Total minimum weight summation of the MST */
c_Allocator_t allocator; /* Deep copy of the user-provided allocator */
} c_BoruvkaMST_t;
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
/**
* @brief Computes a minimum spanning tree of an edge-weighted graph using Boruvka's algorithm.
* @param allocator Explicit allocator context used to configure internal tracking state memory
*/
c_err_t c_BoruvkaMST_Init(c_BoruvkaMST_t* self, c_EdgeWeightedGraph_t* graph, c_Allocator_t* allocator);
/**
* @brief Releases internal tracking buffers
*/
void c_BoruvkaMST_Destroy(c_BoruvkaMST_t* self);
/**
* @brief Gets a copy of the edge ids included in the Minimum Spanning Tree.
*/
c_err_t c_BoruvkaMST_GetEdges(c_BoruvkaMST_t* self, c_VertexIdList_t* out_edges);
/**
* @brief Returns the total weight summation of the MST.
*/
C_STATIC_FORCE_INLINE
double c_BoruvkaMST_Weight(c_BoruvkaMST_t* self) {
return self ? self->weight : 0.0;
}
#endif /*INCLUDED_C_BORUVKAMST_H*/