Skip to main content

MolGraphExt

Trait MolGraphExt 

Source
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§

Source

fn num_atoms(&self) -> usize

Number of atoms (heavy atoms only, no implicit hydrogens).

Source

fn num_bonds(&self) -> usize

Number of bonds in the graph.

Source

fn atom(&self, idx: NodeIndex) -> &Atom

Access atom data by node index.

Source

fn atom_mut(&mut self, idx: NodeIndex) -> &mut Atom

Mutably access atom data by node index.

Source

fn bond_between(&self, a: NodeIndex, b: NodeIndex) -> Option<BondType>

Bond type between two atoms, or None if not bonded.

Source

fn heavy_neighbors(&self, idx: NodeIndex) -> Vec<NodeIndex>

All non-hydrogen neighbor indices.

Source

fn degree(&self, idx: NodeIndex) -> usize

Number of neighbors (graph degree).

Source

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
Source

fn assign_implicit_hydrogens(&mut self)

Set h_count on all atoms. Call after graph is fully constructed.

Implementors§