Skip to main content

Module graph

Module graph 

Source
Expand description

Graph adjacency infrastructure for molecular structures.

Provides pre-computed adjacency lists and degree vectors for efficient graph-based algorithms (ring perception, featurization, fingerprints).

§Example

use sdfrust::{Molecule, Atom, Bond, BondOrder};
use sdfrust::graph::AdjacencyList;

let mut mol = Molecule::new("methane");
mol.atoms.push(Atom::new(0, "C", 0.0, 0.0, 0.0));
mol.atoms.push(Atom::new(1, "H", 1.0, 0.0, 0.0));
mol.atoms.push(Atom::new(2, "H", -1.0, 0.0, 0.0));
mol.bonds.push(Bond::new(0, 1, BondOrder::Single));
mol.bonds.push(Bond::new(0, 2, BondOrder::Single));

let adj = AdjacencyList::from_molecule(&mol);
assert_eq!(adj.degree(0), 2);
assert_eq!(adj.neighbors(0), &[(1, 0), (2, 1)]);

Structs§

AdjacencyList
Pre-computed adjacency list for a molecule’s bond graph.