fn add_vertex(&mut self) -> usize {
        if let Some(reusable_id) = self.next_reusable_vertex_id() {
            self.vertex_count += 1;

            reusable_id
        } else {
            let new_size = if self.is_directed() {
                // AdjMatrix must allocate a new row(|V|), a new column(|V|) and a slot for the new diagonal entry(1):
                // #    #   *
                // #    #   *
                // *    *   *
                // which causes the new length to be: old_length + |V| + |V| + 1 => old_length + 2 * |V| + 1.
                self.vec.len() + 2 * self.total_vertex_count() + 1
            } else {
                // AdjMatrix must only allocate a new row(|V|) and a slot for the new diagonal entry(1).
                // #
                // #    #
                // *    *   *
                // which causes the new length to be: old_length + |V| + 1.
                self.vec.len() + self.total_vertex_count() + 1
            };

            self.vec.resize_with(new_size, || vec![]);

            self.vertex_count += 1;

            self.vertex_count - 1
        }
    }
/// Adds a vertex to the storage.
///
/// # Returns
/// Unique id of the newly added vertex.
///
/// # Complexity
/// O(|V|)
///
/// # Panics
/// If number of vertices exceeds the maximum value that `usize` can represent.
Adds a vertex to the storage.
Adds a vertex to the storage .
fn add_vertex(&mut self) -> usize {
        if let Some(reusable_id) = self.next_reusable_vertex_id() {
            self.vertex_count += 1;
            reusable_id
        } else {
            let new_size = if self.is_directed() {
                // AdjMatrix must allocate a new row(|V|), a new column(|V|) and a slot for the new diagonal entry(1):
                // #    #   *
                // #    #   *
                // *    *   *
                // which causes the new length to be: old_length + |V| + |V| + 1 => old_length + 2 * |V| + 1.
                self.vec.len() + 2 * self.total_vertex_count() + 1
            } else {
                // AdjMatrix must only allocate a new row(|V|) and a slot for the new diagonal entry(1).
                // #
                // #    #
                // *    *   *
                // which causes the new length to be: old_length + |V| + 1.
                self.vec.len() + self.total_vertex_count() + 1
            };
            self.vec.resize_with(new_size, || vec![]);
            self.vertex_count += 1;
            self.vertex_count - 1
        }
    }
fn add_vertex ( & mut self ) -> usize { if let Some ( reusable_id ) = self . next_reusable_vertex_id ( ) { self . vertex_count += 1 ; reusable_id } else { let new_size = if self . is_directed ( ) { // AdjMatrix must allocate a new row(|V|), a new column(|V|) and a slot for the new diagonal entry(1): // #    #   * // #    #   * // *    *   * // which causes the new length to be: old_length + |V| + |V| + 1 => old_length + 2 * |V| + 1. self . vec . len ( ) + 2 * self . total_vertex_count ( ) + 1 } else { // AdjMatrix must only allocate a new row(|V|) and a slot for the new diagonal entry(1). // # // #    # // *    *   * // which causes the new length to be: old_length + |V| + 1. self . vec . len ( ) + self . total_vertex_count ( ) + 1 } ; self . vec . resize_with ( new_size , | | vec ! [ ] ) ; self . vertex_count += 1 ; self . vertex_count - 1 } }
Adds a vertex to the storage.
Adds a vertex to the storage .
&mut self
Unique id of the newly added vertex.
Unique id of the newly added vertex .
&mut self
complexity
None
panics
If number of vertices exceeds the maximum value that `usize` can represent.
If number of vertices exceeds the maximum value that ` usize ` can represent .