hypergraph/core/hyperedges/
reverse_hyperedge.rs

1use rayon::prelude::*;
2
3use crate::{
4    HyperedgeIndex,
5    HyperedgeTrait,
6    Hypergraph,
7    VertexTrait,
8    errors::HypergraphError,
9};
10
11impl<V, HE> Hypergraph<V, HE>
12where
13    V: VertexTrait,
14    HE: HyperedgeTrait,
15{
16    // Reverses a hyperedge.
17    pub fn reverse_hyperedge(
18        &mut self,
19        hyperedge_index: HyperedgeIndex,
20    ) -> Result<(), HypergraphError<V, HE>> {
21        // Get the vertices of the hyperedge.
22        let vertices = self.get_hyperedge_vertices(hyperedge_index)?;
23
24        // Update the hyperedge with the reversed vertices.
25        self.update_hyperedge_vertices(hyperedge_index, vertices.into_par_iter().rev().collect())
26    }
27}