Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b29bbee5 authored by Ricardo Buring's avatar Ricardo Buring
Browse files

Simplify return type of UndirectedGraph::normal_form

Return either vertex orbits or edge orbits, not both.
parent 84eb8f27
Branches master
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ pub fn expand_n_contract(
// NOTE: Start with the normal form of the wheel graph.
let mut wheel_graph: UndirectedGraph = UndirectedGraph::wheel_graph(num_spokes);
let (wheel_graph_sign, wheel_graph_vertex_orbits, _) = wheel_graph.normal_form(false);
let (wheel_graph_sign, wheel_graph_vertex_orbits) = wheel_graph.normal_form(false);
assert!(wheel_graph_sign != 0);
cocycle_graphs.push(wheel_graph.clone());
cocycle_graph_index.insert(wheel_graph, 0);
......@@ -51,8 +51,7 @@ pub fn expand_n_contract(
writeln!(sparse_matrix_file, "{} {} {}", dg_idx + 1, g_idx + 1, c)?;
num_nonzeros += 1;
let cg_data: HashMap<UndirectedGraph, Vec<usize>> =
dg.contractions(&dg_edge_orbits);
let cg_data: HashMap<UndirectedGraph, Vec<usize>> = dg.contractions(&dg_edge_orbits);
for (cg, cg_vertex_orbits) in cg_data {
// eprintln!("{:?}", cg);
if !cocycle_graph_index.contains_key(&cg) {
......
......@@ -241,7 +241,7 @@ impl UndirectedGraph {
}
}
pub fn normal_form(&mut self, compute_edge_orbits: bool) -> (i32, Vec<usize>, Vec<usize>) {
pub fn normal_form(&mut self, compute_edge_orbits: bool) -> (i32, Vec<usize>) {
let mut options: nauty_Traces_sys::optionblk = nauty_Traces_sys::optionblk {
getcanon: nauty_Traces_sys::TRUE,
userautomproc: Some(Self::process_nauty_automorphism),
......@@ -292,11 +292,6 @@ impl UndirectedGraph {
lab_inv[lab[i] as usize] = i as i32;
}
let normal_self_orbits: Vec<usize> = orbits
.iter()
.map(|&v| lab_inv[v as usize] as usize)
.collect();
let mut sign: i32 = 1;
let mut normal_self_edge_orbits: Vec<usize> = vec![];
Self::EDGE_ORBIT_DATA.with_borrow_mut(|edge_orbit_data: &mut EdgeOrbitData| {
......@@ -321,7 +316,15 @@ impl UndirectedGraph {
self.nauty_graph = normal_self.nauty_graph;
(sign, normal_self_orbits, normal_self_edge_orbits)
if compute_edge_orbits {
(sign, normal_self_edge_orbits)
} else {
let normal_self_orbits: Vec<usize> = orbits
.iter()
.map(|&v| lab_inv[v as usize] as usize)
.collect();
(sign, normal_self_orbits)
}
}
fn expand_vertex(&self, &position: &usize) -> Vec<(i64, UndirectedGraph)> {
......@@ -474,9 +477,7 @@ impl UndirectedGraph {
for (orbit_rep, orbit_size) in orbit_reps {
for (c, mut dg) in self.expand_vertex(&orbit_rep) {
// TODO: Avoid computing orbits when not used.
let (normal_dg_sign, _normal_dg_orbits, normal_dg_edge_orbits) =
dg.normal_form(true);
let (normal_dg_sign, normal_dg_edge_orbits) = dg.normal_form(true);
if normal_dg_sign == 0 {
continue;
}
......@@ -568,7 +569,7 @@ impl UndirectedGraph {
nauty_graph: contracted_graph,
};
let (normal_cg_sign, normal_cg_orbits, _) = cg.normal_form(false);
let (normal_cg_sign, normal_cg_orbits) = cg.normal_form(false);
if normal_cg_sign == 0 {
continue;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment