pub struct GeneralMatching {
size: usize,
graph: Vec<Vec<usize>>,
mate: Vec<usize>,
matching_size: usize,
}Fields§
§size: usize§graph: Vec<Vec<usize>>§mate: Vec<usize>§matching_size: usizeImplementations§
Source§impl GeneralMatching
impl GeneralMatching
Sourcepub fn from_edges(size: usize, edges: &[(usize, usize)]) -> Self
pub fn from_edges(size: usize, edges: &[(usize, usize)]) -> Self
Sourcepub fn maximum_matching(&mut self) -> Vec<(usize, usize)>
pub fn maximum_matching(&mut self) -> Vec<(usize, usize)>
Sourcefn augment(&mut self, v: usize, p: &[usize])
fn augment(&mut self, v: usize, p: &[usize])
Examples found in repository?
crates/competitive/src/graph/general_matching.rs (line 65)
48 fn compute(&mut self) {
49 if self.matching_size != !0 {
50 return;
51 }
52 let mut cnt = 0usize;
53 for &m in &self.mate {
54 if m != !0 {
55 cnt += 1;
56 }
57 }
58 self.matching_size = cnt / 2;
59
60 let mut p = vec![!0; self.size];
61 for v in 0..self.size {
62 if self.mate[v] == !0 {
63 let finish = self.find_path(v, &mut p);
64 if finish != !0 {
65 self.augment(finish, &p);
66 self.matching_size += 1;
67 }
68 }
69 }
70 }Sourcefn find_path(&self, root: usize, p: &mut [usize]) -> usize
fn find_path(&self, root: usize, p: &mut [usize]) -> usize
Examples found in repository?
crates/competitive/src/graph/general_matching.rs (line 63)
48 fn compute(&mut self) {
49 if self.matching_size != !0 {
50 return;
51 }
52 let mut cnt = 0usize;
53 for &m in &self.mate {
54 if m != !0 {
55 cnt += 1;
56 }
57 }
58 self.matching_size = cnt / 2;
59
60 let mut p = vec![!0; self.size];
61 for v in 0..self.size {
62 if self.mate[v] == !0 {
63 let finish = self.find_path(v, &mut p);
64 if finish != !0 {
65 self.augment(finish, &p);
66 self.matching_size += 1;
67 }
68 }
69 }
70 }Trait Implementations§
Source§impl Clone for GeneralMatching
impl Clone for GeneralMatching
Source§fn clone(&self) -> GeneralMatching
fn clone(&self) -> GeneralMatching
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GeneralMatching
impl RefUnwindSafe for GeneralMatching
impl Send for GeneralMatching
impl Sync for GeneralMatching
impl Unpin for GeneralMatching
impl UnsafeUnpin for GeneralMatching
impl UnwindSafe for GeneralMatching
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more