Mentions légales du service

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

Move normal form computation for self out of expanding_differential

parent 7ad8f23f
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,9 @@ fn main() {
println!("g = {:?}", g);
println!("g.to_nauty() = {:?}", g.to_nauty());
println!("UndirectedGraph::from_nauty(&g.to_nauty()) = {:?}", UndirectedGraph::from_nauty(&g.to_nauty()));
println!("g.normal_form() = {:?}", g.normal_form());
println!("g.expanding_differential() = {:?}", g.expanding_differential());
let (_sign, normal_g, orbits) = g.normal_form();
println!("normal_g = {:?}", normal_g);
println!("normal_g.expanding_differential(orbits) = {:?}", normal_g.expanding_differential(&orbits));
let triangle: UndirectedGraph = UndirectedGraph::new(3, vec![(0,1), (1,2), (0,2)]);
println!("triangle.normal_form() = {:?}", triangle.normal_form());
}
......@@ -257,32 +257,30 @@ impl UndirectedGraph {
return expansion;
}
pub fn expanding_differential(&self) -> HashMap<UndirectedGraph, i64> {
pub fn expanding_differential(
&self,
orbits: &HashMap<usize, usize>,
) -> HashMap<UndirectedGraph, i64> {
let mut diff: HashMap<UndirectedGraph, i64> = HashMap::new();
// TODO: Move this normal form computation out to avoid redundant re-computation.
let (sign, normal_self, orbits) = self.normal_form();
if sign != 0 {
for (orbit_rep, orbit_size) in orbits {
for (c, dg) in normal_self.expand_vertex(&orbit_rep) {
// TODO: Avoid computing orbits when not used.
let (normal_dg_sign, normal_dg, _normal_dg_orbits) = dg.normal_form();
if normal_dg_sign == 0 {
continue;
}
// TODO: Fix coefficient types.
let normal_dg_coeff: i64 =
(normal_dg_sign as i64) * (sign as i64) * (orbit_size as i64) * (c as i64);
if let Some(diff_coeff) = diff.get_mut(&normal_dg) {
*diff_coeff += normal_dg_coeff;
} else {
diff.insert(normal_dg, normal_dg_coeff);
}
for (&orbit_rep, &orbit_size) in orbits {
for (c, dg) in self.expand_vertex(&orbit_rep) {
// TODO: Avoid computing orbits when not used.
let (normal_dg_sign, normal_dg, _normal_dg_orbits) = dg.normal_form();
if normal_dg_sign == 0 {
continue;
}
// TODO: Fix coefficient types.
let normal_dg_coeff: i64 =
(normal_dg_sign as i64) * (orbit_size as i64) * (c as i64);
if let Some(diff_coeff) = diff.get_mut(&normal_dg) {
*diff_coeff += normal_dg_coeff;
} else {
diff.insert(normal_dg, normal_dg_coeff);
}
}
diff.retain(|_dg, dg_coeff| *dg_coeff != 0);
}
diff.retain(|_dg, dg_coeff| *dg_coeff != 0);
return diff;
}
......
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