Mentions légales du service

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

UndirectedGraph::contractions: take edge orbits as input

parent 5efcb29c
Branches master
No related tags found
No related merge requests found
......@@ -11,8 +11,8 @@ fn main() {
println!("normal_g.expanding_differential(&orbits) = {:?}", normal_g.expanding_differential(&orbits));
println!("normal_g.contractions() = {:?}", normal_g.contractions(&vec![0_usize]));
let h: UndirectedGraph = UndirectedGraph::new(7,vec![(0, 1), (0, 2), (0, 6), (1, 4), (1, 6), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6), (4, 5)]);
let edge_orbit_reps_h: Vec<usize> = vec![0, 2, 3, 4, 7, 9, 10];
println!("normal_h.contractions(&edge_orbits_h) = {:?}", h.contractions(&edge_orbit_reps_h));
let edge_orbits_h: Vec<usize> = vec![0, 0, 2, 3, 4, 3, 4, 10, 7, 7, 9];
println!("normal_h.contractions(&edge_orbits_h) = {:?}", h.contractions(&edge_orbits_h));
let triangle: UndirectedGraph = UndirectedGraph::new(3, vec![(0,1), (1,2), (0,2)]);
println!("triangle.normal_form() = {:?}", triangle.normal_form(true));
println!("triangle.contractions() = {:?}", triangle.contractions(&vec![0_usize]));
......
......@@ -324,11 +324,16 @@ impl UndirectedGraph {
pub fn contractions(
&self,
edge_orbit_reps: &Vec<usize>,
edge_orbits: &Vec<usize>,
) -> HashMap<UndirectedGraph, HashMap<usize, usize>> {
// TODO: Check that passing around hashmaps is not too expensive.
let mut contractions: HashMap<UndirectedGraph, HashMap<usize, usize>> = HashMap::new();
for &edge_orbit_rep in edge_orbit_reps {
let mut edge_orbit_reps: HashSet<usize> = HashSet::new();
for &edge_orbit_rep in edge_orbits {
// Skip orbits already seen.
if !edge_orbit_reps.insert(edge_orbit_rep) {
continue;
}
let edge: (usize, usize) = self.edges[edge_orbit_rep];
// TODO: Optimize the computation of new_edges.
let mut new_edges: Vec<(usize, usize)> = self.edges.clone();
......
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