/// Returns the indices of the vertices of a Petrial polygon in cyclic
/// order, or `None` if it self-intersects.
///
/// # Panics
/// Panics if the polytope is not sorted.
Returns the indices of the vertices of a Petrial polygon in cyclic
order, or `None` if it self-intersects.
Returns the indices of the vertices of a Petrial polygon in cyclic order or ` None ` if it self - intersects .
fn petrie_polygon_vertices(&self, flag: Flag) -> Option<Vec<usize>> {
        let rank = self.rank();
        let mut new_flag = flag.clone();
        let first_vertex = flag[0];
        let mut vertices = Vec::new();
        let mut vertex_hash = HashSet::new();
        assert!(self.abs().sorted());
        loop {
            // Applies 0-changes up to (rank-1)-changes in order.
            for idx in 0..rank {
                new_flag.change_mut(self.abs(), idx);
            }
            // If we just hit a previous vertex, we return.
            let new_vertex = new_flag[0];
            if vertex_hash.contains(&new_vertex) {
                return None;
            }
            // Adds the new vertex.
            vertices.push(new_vertex);
            vertex_hash.insert(new_vertex);
            // If we're back to the beginning, we break out of the loop.
            if new_vertex == first_vertex {
                break;
            }
        }
        // We returned to precisely the initial flag.
        (flag == new_flag).then(|| vertices)
    }
fn petrie_polygon_vertices ( & self , flag : Flag ) -> Option < Vec < usize > > { let rank = self . rank ( ) ; let mut new_flag = flag . clone ( ) ; let first_vertex = flag [ 0 ] ; let mut vertices = Vec :: new ( ) ; let mut vertex_hash = HashSet :: new ( ) ; assert ! ( self abs ( ) sorted ( ) ) ; loop { // Applies 0-changes up to (rank-1)-changes in order. for idx in 0 .. rank { new_flag . change_mut ( self . abs ( ) , idx ) ; } // If we just hit a previous vertex, we return. let new_vertex = new_flag [ 0 ] ; if vertex_hash . contains ( & new_vertex ) { return None ; } // Adds the new vertex. vertices . push ( new_vertex ) ; vertex_hash . insert ( new_vertex ) ; // If we're back to the beginning, we break out of the loop. if new_vertex == first_vertex { break ; } } // We returned to precisely the initial flag. ( flag == new_flag ) . then ( | | vertices ) }
Returns the indices of the vertices of a Petrial polygon in cyclic
order, or `None` if it self-intersects.
Returns the indices of the vertices of a Petrial polygon in cyclic order or ` None ` if it self - intersects .
&self
flag
Flag
panics
Panics if the polytope is not sorted.
Panics if the polytope is not sorted .