Advanced Chunk Processing Library 0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
advanced_structures::GraphBasedChunk< T > Class Template Reference

Graph-based chunking implementation. More...

#include <advanced_structures.hpp>

Public Member Functions

 GraphBasedChunk (double threshold=0.5)
 
std::vector< std::vector< T > > chunk (const std::vector< T > &data)
 

Protected Member Functions

virtual void buildGraph (const std::vector< T > &data, Graph &g)
 

Private Types

using Graph = boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS >
 

Private Attributes

double edge_threshold
 

Detailed Description

template<typename T>
class advanced_structures::GraphBasedChunk< T >

Graph-based chunking implementation.

Template Parameters
TThe type of elements to be chunked

Definition at line 627 of file advanced_structures.hpp.

Member Typedef Documentation

◆ Graph

template<typename T >
using advanced_structures::GraphBasedChunk< T >::Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>
private

Definition at line 629 of file advanced_structures.hpp.

Constructor & Destructor Documentation

◆ GraphBasedChunk()

template<typename T >
advanced_structures::GraphBasedChunk< T >::GraphBasedChunk ( double  threshold = 0.5)
inlineexplicit

Definition at line 633 of file advanced_structures.hpp.

Member Function Documentation

◆ buildGraph()

template<typename T >
virtual void advanced_structures::GraphBasedChunk< T >::buildGraph ( const std::vector< T > &  data,
Graph g 
)
inlineprotectedvirtual

Definition at line 655 of file advanced_structures.hpp.

655 {
656 // Default implementation: connect adjacent elements
657 for (size_t i = 1; i < data.size(); ++i) {
658 boost::add_edge(i - 1, i, g);
659 }
660 }

Referenced by advanced_structures::GraphBasedChunk< T >::chunk().

◆ chunk()

template<typename T >
std::vector< std::vector< T > > advanced_structures::GraphBasedChunk< T >::chunk ( const std::vector< T > &  data)
inline

Definition at line 635 of file advanced_structures.hpp.

635 {
636 std::vector<std::vector<T>> result;
637 if (data.empty())
638 return result;
639
640 Graph g(data.size());
641 buildGraph(data, g);
642
643 std::vector<int> components(data.size());
644 int num_components = boost::connected_components(g, &components[0]);
645
646 result.resize(num_components);
647 for (size_t i = 0; i < data.size(); ++i) {
648 result[components[i]].push_back(data[i]);
649 }
650
651 return result;
652 }
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS > Graph
virtual void buildGraph(const std::vector< T > &data, Graph &g)

References advanced_structures::GraphBasedChunk< T >::buildGraph().

Referenced by TEST().

Member Data Documentation

◆ edge_threshold

template<typename T >
double advanced_structures::GraphBasedChunk< T >::edge_threshold
private

Definition at line 630 of file advanced_structures.hpp.


The documentation for this class was generated from the following file: