Skip to main content

Module constants

Module constants 

Source
Expand description

Rust enumerations for igraph’s C constants (igraph_constants.h).

Each enum converts into the raw C value with From (e.g. igraph_neimode_t::from(NeighborMode::Out)), and back with TryFrom (an ErrorKind::InvalidValue error for values that are not part of the enumeration). All of them are re-exported by the prelude. Module-specific enums (e.g. layout or community options) live next to the functions that use them.

use igraph::{ffi, prelude::*};

// Out-neighbors follow the edge direction, in-neighbors go against it.
let g = Graph::from_edges(&[(0, 1), (2, 1), (1, 1)], 3, true).unwrap();
assert_eq!(g.neighbors(1, NeighborMode::Out).unwrap(), vec![1]);
assert_eq!(g.neighbors(1, NeighborMode::In).unwrap(), vec![0, 1, 2]);
assert_eq!(g.degree(1, NeighborMode::All, Loops::Twice).unwrap(), vec![4]);
assert_eq!(g.degree(1, NeighborMode::All, Loops::None).unwrap(), vec![2]);

// Conversions to and from the raw C constants.
assert_eq!(ffi::igraph_neimode_t::from(NeighborMode::In), ffi::igraph_neimode_t_IGRAPH_IN);
assert_eq!(NeighborMode::try_from(ffi::igraph_neimode_t_IGRAPH_ALL).unwrap(), NeighborMode::All);
assert!(Order::try_from(42 as ffi::igraph_order_t).is_err());
EnumC typeUsed by (for example)
NeighborModeigraph_neimode_tGraph::neighbors, Graph::degree, Graph::bfs, Graph::distances
Loopsigraph_loops_tGraph::degree, Graph::neighbors_with, Graph::get_adjacency
EdgeTypeSw, AllowedEdgeTypesigraph_edge_type_sw_tGraph::rewire, Graph::erdos_renyi_game_gnm
Orderigraph_order_tVectorInt::sort_ind, Graph::sort_vertex_ids_by_degree
Connectednessigraph_connectedness_tGraph::connected_components, Graph::is_connected
Reciprocityigraph_reciprocity_tGraph::reciprocity
Adjacency, GetAdjacencyigraph_adjacency_t, igraph_get_adjacency_tGraph::adjacency, Graph::get_adjacency
StarMode, WheelMode, TreeModeigraph_star_mode_t, igraph_wheel_mode_t, igraph_tree_mode_tGraph::star, Graph::wheel, Graph::kary_tree
DegreeSequenceMethod, RealizeDegseqigraph_degseq_t, igraph_realize_degseq_tGraph::degree_sequence_game, Graph::realize_degree_sequence
RandomTreeMethod, BarabasiAlgorithm, ChungLuVariantigraph_random_tree_t, igraph_barabasi_algorithm_t, igraph_chung_lu_tGraph::tree_game, Graph::barabasi_game, Graph::chung_lu_game
EdgeOrderigraph_edgeorder_type_tEdgeSelector::AllOrdered
ToDirected, ToUndirectedigraph_to_directed_t, igraph_to_undirected_tGraph::to_directed, Graph::to_undirected
VconnNeiigraph_vconn_nei_tGraph::st_vertex_connectivity
SpincommUpdate, SpinglassImplementation, LpaVariant, CommunityComparisonigraph_spincomm_update_t, …Graph::community_spinglass, Graph::community_label_propagation, compare_communities
TransitivityModeigraph_transitivity_mode_tGraph::transitivity_local_undirected
AddWeightsigraph_add_weights_tNcolLglOptions
FasAlgorithm, FvsAlgorithmigraph_fas_algorithm_t, igraph_fvs_algorithm_tGraph::feedback_arc_set, Graph::feedback_vertex_set
SubgraphImplementationigraph_subgraph_implementation_tGraph::induced_subgraph
LayoutGridigraph_layout_grid_tFruchtermanReingoldOptions
RandomWalkStuck, VoronoiTiebreakerigraph_random_walk_stuck_t, igraph_voronoi_tiebreaker_tGraph::random_walk, Graph::voronoi
MstAlgorithm, Productigraph_mst_algorithm_t, igraph_product_tGraph::minimum_spanning_tree, Graph::product
MatrixStorageigraph_matrix_storage_traw FFI functions taking flat matrices

Structs§

AllowedEdgeTypes
Which kinds of edges a graph may contain, as a set of flags (igraph_edge_type_sw_t, including the combination IGRAPH_LOOPS_SW | IGRAPH_MULTI_SW).

Enums§

AddWeights
Whether to add weights when converting from matrices (igraph_add_weights_t).
Adjacency
How to interpret an adjacency matrix (igraph_adjacency_t).
BarabasiAlgorithm
Algorithm of the Barabási–Albert generator (igraph_barabasi_algorithm_t).
ChungLuVariant
Variant of the Chung–Lu model (igraph_chung_lu_t).
CommunityComparison
Measure used to compare two community structures (igraph_community_comparison_t).
Connectedness
Weak or strong connectedness (igraph_connectedness_t).
DegreeSequenceMethod
Method for sampling graphs with a given degree sequence (igraph_degseq_t).
EdgeOrder
Edge ordering for edge selectors (igraph_edgeorder_type_t).
EdgeTypeSw
Which kind of edges a random generator may produce (igraph_edge_type_sw_t).
FasAlgorithm
Feedback arc set algorithm (igraph_fas_algorithm_t).
FvsAlgorithm
Feedback vertex set algorithm (igraph_fvs_algorithm_t).
GetAdjacency
Which part of the adjacency matrix to produce for undirected graphs (igraph_get_adjacency_t).
LayoutGrid
Whether force-directed layouts use a grid (igraph_layout_grid_t).
Loops
How self-loops are counted (igraph_loops_t).
LpaVariant
Label propagation variant (igraph_lpa_variant_t).
MatrixStorage
Storage order of matrices given as flat arrays (igraph_matrix_storage_t).
MstAlgorithm
Minimum spanning tree algorithm (igraph_mst_algorithm_t).
NeighborMode
Which neighbors (or incident edges) to consider in directed graphs (igraph_neimode_t). Ignored for undirected graphs.
Order
Sorting order (igraph_order_t).
Product
Kind of graph product (igraph_product_t).
RandomTreeMethod
Random tree sampling algorithm (igraph_random_tree_t).
RandomWalkStuck
What a random walk does when stuck (igraph_random_walk_stuck_t).
RealizeDegseq
Vertex choice when realizing a degree sequence (igraph_realize_degseq_t).
Reciprocity
Reciprocity definition (igraph_reciprocity_t).
SpincommUpdate
Update rule of the spinglass community detection (igraph_spincomm_update_t).
SpinglassImplementation
Spinglass implementation (igraph_spinglass_implementation_t).
StarMode
Orientation of a star graph (igraph_star_mode_t).
SubgraphImplementation
Implementation strategy for induced subgraphs (igraph_subgraph_implementation_t).
ToDirected
How to convert undirected edges to directed ones (igraph_to_directed_t).
ToUndirected
How to convert directed edges to undirected ones (igraph_to_undirected_t).
TransitivityMode
Value of local transitivity for vertices of degree < 2 (igraph_transitivity_mode_t).
TreeMode
Orientation of a tree (igraph_tree_mode_t).
VconnNei
What to do when computing the vertex connectivity of two adjacent vertices, which no vertex removal can disconnect (igraph_vconn_nei_t).
VoronoiTiebreaker
Tie breaking in Voronoi partitioning (igraph_voronoi_tiebreaker_t).
WheelMode
Orientation of a wheel graph (igraph_wheel_mode_t).

Type Aliases§

edge_type_sw_tDeprecated
Former name of EdgeTypeSw, kept for backwards compatibility.