Skip to main content

greedy_coloring_with_order

Function greedy_coloring_with_order 

Source
pub fn greedy_coloring_with_order(
    graph: &Graph,
    order: Option<&[u32]>,
) -> IgraphResult<Vec<u32>>
Expand description

Greedy vertex coloring with a custom vertex processing order.

If order is None, processes vertices in natural order (0, 1, …). Otherwise, processes vertices in the order given by the slice.

§Examples

use rust_igraph::{Graph, greedy_coloring_with_order};

let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let c = greedy_coloring_with_order(&g, Some(&[2, 1, 0])).unwrap();
// All three are mutually adjacent, so 3 colors needed regardless of order
let num_colors = *c.iter().max().unwrap() + 1;
assert_eq!(num_colors, 3);