pub fn is_subgraph(maj_mol : &Molecule, sub_mol : &Molecule) -> bool {

    debug_println!("{}", maj_mol.to_string());
    debug_println!("{}", sub_mol.to_string());
  
    let maj_atoms = &maj_mol.atoms;
    let sub_atoms = &sub_mol.atoms;

    // sub_atom is the first atom in the sub_mol that is not R
    let sub_atom_j = get_not_r(sub_atoms);
    let sub_atom = &sub_atoms[sub_atom_j];

    for i in (0..maj_atoms.len()).rev() {
        let maj_atom = &maj_atoms[i];
        if maj_atom == sub_atom {

            // visited keeps track of the visited sub atoms
            let mut sub_visited = vec![false; sub_atoms.len()];
            let mut maj_visited = vec![false; maj_atoms.len()];
            
            let res = is_subgraph_from_here(maj_mol, i, sub_mol, sub_atom_j ,
                &mut sub_visited, &mut maj_visited);

            if res {return true}
        }
    }
    false
}
// finds sub instances of the subMole in majorMol
// goes through each atom of the majorMol, until it exhausts the search or finds the whole
// subgraph of subMol in majorMol
// Matches atom and bond arrangements\
// Usually, the least common organic atoms are at the end of the list, so it would be more
// efficient to start from the end of the atom vec
// TODO Needs to be optimized.
finds sub instances of the subMole in majorMol
goes through each atom of the majorMol, until it exhausts the search or finds the whole
subgraph of subMol in majorMol
Matches atom and bond arrangements\
Usually, the least common organic atoms are at the end of the list, so it would be more
efficient to start from the end of the atom vec
TODO Needs to be optimized.
finds sub instances of the subMole in majorMol goes through each atom of the majorMol until it exhausts the search or finds the whole subgraph of subMol in majorMol Matches atom and bond arrangements \ Usually the least common organic atoms are at the end of the list so it would be more efficient to start from the end of the atom vec TODO Needs to be optimized .
pub fn is_subgraph(maj_mol : &Molecule, sub_mol : &Molecule) -> bool {
    debug_println!("{}", maj_mol.to_string());
    debug_println!("{}", sub_mol.to_string());
    let maj_atoms = &maj_mol.atoms;
    let sub_atoms = &sub_mol.atoms;
    // sub_atom is the first atom in the sub_mol that is not R
    let sub_atom_j = get_not_r(sub_atoms);
    let sub_atom = &sub_atoms[sub_atom_j];
    for i in (0..maj_atoms.len()).rev() {
        let maj_atom = &maj_atoms[i];
        if maj_atom == sub_atom {
            // visited keeps track of the visited sub atoms
            let mut sub_visited = vec![false; sub_atoms.len()];
            let mut maj_visited = vec![false; maj_atoms.len()];
            let res = is_subgraph_from_here(maj_mol, i, sub_mol, sub_atom_j ,
                &mut sub_visited, &mut maj_visited);
            if res {return true}
        }
    }
    false
}
pub fn is_subgraph ( maj_mol : & Molecule , sub_mol : & Molecule ) -> bool { debug_println ! ( " " maj_mol to_string ( ) ) ; debug_println ! ( " " sub_mol to_string ( ) ) ; let maj_atoms = & maj_mol . atoms ; let sub_atoms = & sub_mol . atoms ; // sub_atom is the first atom in the sub_mol that is not R let sub_atom_j = get_not_r ( sub_atoms ) ; let sub_atom = & sub_atoms [ sub_atom_j ] ; for i in ( 0 .. maj_atoms . len ( ) ) . rev ( ) { let maj_atom = & maj_atoms [ i ] ; if maj_atom == sub_atom { // visited keeps track of the visited sub atoms let mut sub_visited = vec ! [ false sub_atoms len ( ) ] ; let mut maj_visited = vec ! [ false maj_atoms len ( ) ] ; let res = is_subgraph_from_here ( maj_mol , i , sub_mol , sub_atom_j , & mut sub_visited , & mut maj_visited ) ; if res { return true } } } false }
finds sub instances of the subMole in majorMol
goes through each atom of the majorMol, until it exhausts the search or finds the whole
subgraph of subMol in majorMol
Matches atom and bond arrangements\
Usually, the least common organic atoms are at the end of the list, so it would be more
efficient to start from the end of the atom vec
TODO Needs to be optimized.
finds sub instances of the subMole in majorMol goes through each atom of the majorMol until it exhausts the search or finds the whole subgraph of subMol in majorMol Matches atom and bond arrangements \ Usually the least common organic atoms are at the end of the list so it would be more efficient to start from the end of the atom vec TODO Needs to be optimized .
maj_mol
&Molecule
sub_mol
&Molecule
maj_mol
&Molecule
sub_mol
&Molecule