pub fn full_graph(n: u32, directed: bool, loops: bool) -> IgraphResult<Graph>Expand description
Build the full (complete) graph on n vertices.
The semantics follow igraph_full(graph, n, directed, loops):
directed = false, loops = false→K_nwithn·(n−1)/2edges.directed = false, loops = true→K_nplus one self-loop per vertex (n·(n+1)/2edges total).directed = true, loops = false→ directedK_nwith both(i, j)and(j, i)arcs for everyi ≠ j(n·(n−1)arcs).directed = true, loops = true→ above plus a self-loop on every vertex (n²arcs total).
§Errors
IgraphError::InvalidArgument— the upper bound on the edge count (n²in the worst case) overflowsusize, so the edge buffer cannot be sized safely. Computed viausize::checked_mulso the failure mode is deterministic.
§Examples
use rust_igraph::full_graph;
// K_4 — undirected complete graph on 4 vertices, 6 edges.
let k4 = full_graph(4, false, false).unwrap();
assert_eq!(k4.vcount(), 4);
assert_eq!(k4.ecount(), 6);
assert!(!k4.is_directed());
// Directed K_3 with loops — 9 arcs (3 × 3).
let dk3 = full_graph(3, true, true).unwrap();
assert_eq!(dk3.vcount(), 3);
assert_eq!(dk3.ecount(), 9);
assert!(dk3.is_directed());