pub trait MolGraphExt {
// Required methods
fn num_atoms(&self) -> usize;
fn num_bonds(&self) -> usize;
fn atom(&self, idx: NodeIndex) -> &Atom;
fn atom_mut(&mut self, idx: NodeIndex) -> &mut Atom;
fn bond_between(&self, a: NodeIndex, b: NodeIndex) -> Option<BondType>;
fn heavy_neighbors(&self, idx: NodeIndex) -> Vec<NodeIndex>;
fn degree(&self, idx: NodeIndex) -> usize;
fn compute_implicit_h(&self, idx: NodeIndex) -> u8;
fn assign_implicit_hydrogens(&mut self);
}Expand description
Extension trait adding chemistry-aware methods to MolGraph.
Required Methods§
Sourcefn bond_between(&self, a: NodeIndex, b: NodeIndex) -> Option<BondType>
fn bond_between(&self, a: NodeIndex, b: NodeIndex) -> Option<BondType>
Bond type between two atoms, or None if not bonded.
Sourcefn heavy_neighbors(&self, idx: NodeIndex) -> Vec<NodeIndex>
fn heavy_neighbors(&self, idx: NodeIndex) -> Vec<NodeIndex>
All non-hydrogen neighbor indices.
Sourcefn compute_implicit_h(&self, idx: NodeIndex) -> u8
fn compute_implicit_h(&self, idx: NodeIndex) -> u8
Compute implicit H count for an atom.
- If explicit_h is set (bracket atom with H spec), return that.
- For bracket atoms without H spec (explicit_h is None AND atom is bracket), we return 0 — caller decides based on context.
- For organic subset atoms, compute from default valences: implicit_H = min_valence_geq_bond_sum - bond_sum
Sourcefn assign_implicit_hydrogens(&mut self)
fn assign_implicit_hydrogens(&mut self)
Set h_count on all atoms. Call after graph is fully constructed.