A parallelized C++ implementation of the Fractal Net Evolution Approach (FNEA) algorithm for hierarchical graph partitioning, with Python bindings.
This module implements a parallel version of the FNEA algorithm, which creates hierarchical partitions of graphs by iteratively merging nodes based on mutual best-fitting criteria. The algorithm is particularly useful for:
- Point cloud segmentation
- Graph-based clustering
- Hierarchical data analysis
- Supervoxel generation
FNEA performs hierarchical graph partitioning using the following approach:
- Best Merge Selection: For each node, find the neighbor that minimizes heterogeneity increase
- Mutual Best-Fitting: Only merge nodes that are mutual best candidates
- Node Merging: Update node features, positions, and connectivity
- Graph Rebuilding: Compact the graph representation and recompute edge weights
- Iteration: Repeat until no more merges are possible
The parallel implementation uses OpenMP to accelerate the computationally intensive loops.
- Parallel Processing: OpenMP-based parallelization for improved performance
- Feature Heterogeneity: Supports multi-dimensional feature vectors
- Shape Heterogeneity: Incorporates spatial compactness constraints
- Flexible Weighting: Configurable balance between feature and shape heterogeneity
- Python Integration: Easy-to-use Python wrapper with NumPy integration
parallel_fnea/
├── include/ # C++ header files
├── src/ # C++ source files
├── python/ # Python bindings
│ ├── cpython/ # C Python interface
│ ├── wrappers/ # Python wrapper functions
│ └── bin/ # Compiled Python extensions
├── README.md # This file
└── LICENSE # License information
cd python
python setup.py build_extThe compiled module will be available in the bin/ directory.
from parallel_fnea import fnea_partition_level
# Prepare your data
coords = np.array(...) # Node grid coordinates (N x 3)
pos = np.array(...) # Node positions (N x 3)
x = np.array(...) # Node features (N x D)
h = np.array(...) # Node heterogeneity (N x D)
bb = np.array(...) # Bounding boxes (N x 3)
rgb = np.array(...) # Node colors (N x 3)
source_csr = np.array(...) # CSR source indices
target = np.array(...) # CSR target indices
edge_weights = np.array(...) # Edge weights
# Run FNEA partition
super_index, coords_out pos_out, bb_out, rgb_out, x_c, cluster, edges, times = fnea_partition_level(
coords, pos, x, h, bb, rgb, source_csr, target, edge_weights,
vert_weights=node_counts,
scale_factor=10.0,
compactness=0.2,
spatial_weight=0.5,
verbose=True,
max_num_threads=4
)scale_factor: Controls partition coarseness (higher values = coarser partitions)compactness: Spatial compactness weight [0, 1]spatial_weight: Balance between feature and spatial heterogeneity [0, 1]max_num_threads: Maximum number of OpenMP threads to useverbose: Enable progress output
The parallel implementation provides significant speedup over the pure Python version, especially for large graphs:
- Small graphs (< 1K nodes): 2-3x speedup
- Medium graphs (1K-10K nodes): 5-10x speedup
- Large graphs (> 10K nodes): 10-20x speedup
Performance scales well with the number of available CPU cores.
This implementation is based on the Fractal Net Evolution Approach for hierarchical graph partitioning, adapted for modern parallel computing environments.
This software is under the GPLv3 license.