#[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_tImplementations§
Source§impl igraph_t
impl igraph_t
pub fn setup()
Sourcepub fn erdos_renyi_game_gnm(
num_vertices: usize,
num_edges: usize,
directed: bool,
mode: edge_type_sw_t,
edge_attr: bool,
) -> Self
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.
pub fn new(num_vertices: usize, directed: bool) -> Self
pub fn num_vertices(&self) -> i64
pub fn num_edges(&self) -> i64
pub fn is_directed(&self) -> bool
pub fn add_vertices(&mut self, n: i64)
pub fn add_edge(&mut self, from: i64, to: i64)
pub fn add_edges_from_slice(&mut self, edges_slice: &[(i64, i64)])
pub fn add_edges_from_vector(&mut self, edges: &igraph_vector_int_t)
Sourcepub fn diameter(&self) -> f64
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.