igraph_t

Struct igraph_t 

Source
#[repr(C)]
pub struct igraph_t { pub n: igraph_int_t, pub directed: igraph_bool_t, pub from: igraph_vector_int_t, pub to: igraph_vector_int_t, pub oi: igraph_vector_int_t, pub ii: igraph_vector_int_t, pub os: igraph_vector_int_t, pub is: igraph_vector_int_t, pub attr: *mut c_void, pub cache: *mut igraph_i_property_cache_t, }
Expand description

\ingroup internal \struct igraph_t \brief The internal data structure for storing graphs.

It is simple and efficient. It has the following members:

  • n The number of vertices, redundant.
  • directed Whether the graph is directed.
  • from The first column of the edge list.
  • to The second column of the edge list.
  • oi The index of the edge list by the first column. Thus the first edge according to this order goes from \c from[oi[0]] to \c to[oi[0]]. The length of this vector is the same as the number of edges in the graph.
  • ii The index of the edge list by the second column. The length of this vector is the same as the number of edges.
  • os Contains pointers to the edgelist (\c from and \c to for every vertex. The first edge \em from vertex \c v is edge no. \c from[oi[os[v]]] if \c os[v]<os[v+1]. If \c os[v]==os[v+1] then there are no edges \em from node \c v. Its length is the number of vertices plus one, the last element is always the same as the number of edges and is contained only to ease the queries.
  • is This is basically the same as os, but this time for the incoming edges.

For undirected graphs, the same edge list is stored, i.e. an undirected edge is stored only once. Currently, undirected edges are canonicalized so that the index of the ‘from’ vertex is not greater than the index of the ‘to’ vertex. Thus, if v1 <= v2, only the edge (v1, v2) needs to be searched for, not (v2, v1), to determine if v1 and v2 are connected. However, this fact is NOT guaranteed by the documented public API, and should not be relied upon by the implementation of any functions, except those belonging to the minimal API in type_indexededgelist.c.

The storage requirements for a graph with \c |V| vertices and \c |E| edges is \c O(|E|+|V|).

Fields§

§n: igraph_int_t§directed: igraph_bool_t§from: igraph_vector_int_t§to: igraph_vector_int_t§oi: igraph_vector_int_t§ii: igraph_vector_int_t§os: igraph_vector_int_t§is: igraph_vector_int_t§attr: *mut c_void§cache: *mut igraph_i_property_cache_t

Implementations§

Source§

impl igraph_t

Source

pub fn setup()

Source

pub fn erdos_renyi_game_gnm( num_vertices: usize, num_edges: usize, directed: bool, mode: edge_type_sw_t, edge_attr: bool, ) -> Self

In the G(n, m) Erdős-Rényi model, a graph with n vertices and m edges is generated uniformly at random; for the sake of clarity, it binds the igraph_erdos_renyi_game_gnm function.

Source

pub fn new(num_vertices: usize, directed: bool) -> Self

Source

pub fn num_vertices(&self) -> i64

Source

pub fn num_edges(&self) -> i64

Source

pub fn is_directed(&self) -> bool

Source

pub fn add_vertices(&mut self, n: i64)

Source

pub fn add_edge(&mut self, from: i64, to: i64)

Source

pub fn add_edges_from_slice(&mut self, edges_slice: &[(i64, i64)])

Source

pub fn add_edges_from_vector(&mut self, edges: &igraph_vector_int_t)

Source

pub fn diameter(&self) -> f64

Calculates the diameter of a graph (longest geodesic):

The diameter of a graph is the length of the longest shortest path it has. This function computes both the diameter, as well as the corresponding path. The diameter of the null graph is considered be infinity by convention. If the graph has no vertices, IGRAPH_NAN is returned.

Source

pub fn mean_degree(&self, loops: bool) -> f64

Source

pub fn community_multilevel(&self, resolution: f64) -> Vec<i64>

Trait Implementations§

Source§

impl Clone for igraph_t

Source§

fn clone(&self) -> igraph_t

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for igraph_t

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for igraph_t

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.