relabel()
The graph with atom k of the result = atom atom_map[k] of gra.
Usage
relabel(gra: G, atom_map: Sequence[int]) -> G
relabel(gra: AnyGraph, atom_map: Sequence[int]) -> AnyGraphSame direction as AutoStorage’s link atom_map (P22), whose atom_map[k] is the input index of canonical atom k: relabel(gra, atom_map) gives the canonical graph, and the inverse map (numpy.argsort(atom_map)) gives gra back.
>>> g = MolGraph(symbols=["O", "H", "H"], bonds=[(0, 1), (0, 2)])
>>> relabel(g, [2, 0, 1])MolGraph(symbols=(‘H’, ‘O’, ‘H’), bonds=((0, 1), (1, 2)), charge=0, spin=0)
>>> relabel(relabel(g, [2, 0, 1]), [1, 2, 0]) == g # [1, 2, 0] is the inverseTrue
Raises
ValueError-
If
atom_mapis not a permutation of the atoms.