graphdot package¶
The GraphDot library for graph similarity comparison
-
class
graphdot.
Graph
(nodes, edges, title='')[source]¶ Bases:
object
This is the class that stores a graph in GraphDot.
Parameters: - nodes (dataframe) – each row represent a node
- edges (dataframe) – each row represent an edge
- title (str) – a unique identifier of the graph
-
adjacency_matrix
¶ Get the adjacency matrix of the graph as a sparse matrix.
Returns: adjacency_matrix – The adjacency matrix, either weighted or unweighted depending on the original graph. Return type: sparse matrix
-
copy
(deep=False)[source]¶ Make a copy of an existing graph.
Parameters: deep (boolean) – If deep=True, then real copies will be made for the node and edge dataframes as well as other user-specified attributes. Otherwise, only references to the dataframe columns and user-specified attributes will be inserted into the new graph. Returns: g – A new graph. Return type: Graph
-
classmethod
from_ase
(atoms, adjacency='default', use_charge=False, use_pbc=True)[source]¶ Convert from ASE atoms to molecular graph
Parameters: - atoms (ASE Atoms object) – A molecule as represented by a collection of atoms in 3D space.
- usb_pbc (boolean or list of 3 booleans) – Whether to use the periodic boundary condition as specified in the atoms object to create edges between atoms.
- adjacency ('default' or object) – A functor that implements the rule for making edges between atoms.
Returns: a molecular graph where atoms become nodes while edges resemble short-range interatomic interactions.
Return type:
-
classmethod
from_networkx
(graph, weight=None)[source]¶ Convert from NetworkX
Graph
Parameters: - graph (a NetworkX
Graph
instance) – an undirected graph with homogeneous node and edge features, i.e. carrying same features. - weight (str) – name of the attribute that encode edge weights
Returns: the converted graph
Return type: - graph (a NetworkX
-
classmethod
from_pymatgen
(molecule, use_pbc=True, adjacency='default')[source]¶ Convert from pymatgen molecule to molecular graph
Parameters: - molecule (pymatgen Molecule object) – A molecule as represented by a collection of atoms in 3D space.
- usb_pbc (boolean or list of 3 booleans) – Whether to use the periodic boundary condition as specified in the atoms object to create edges between atoms.
- adjacency ('default' or object) – A functor that implements the rule for making edges between atoms.
Returns: A molecular graph where atoms become nodes while edges resemble short-range interatomic interactions.
Return type:
-
classmethod
from_rdkit
(mol, title=None, bond_type='order', set_ring_list=True, set_ring_stereo=True)[source]¶ Convert a RDKit molecule to a graph
Parameters: - bond_type ('order' or 'type') – If ‘order’, an edge attribute ‘order’ will be populated with
numeric values such as 1 for single bonds, 2 for double bonds, and
1.5 for aromatic bonds. If ‘type’, an attribute ‘type’ will be
populated with
rdkit.Chem.BondType
values. - set_ring_list (bool) – if True, a nodal attribute ‘ring_list’ will be used to store a list of the size of the rings that the atom participates in.
- set_ring_stereo (bool) – If True, an edge attribute ‘ring_stereo’ will be used to store the E-Z stereo configuration of substitutes at the end of each bond along a ring.
Returns: A graph where nodes represent atoms and edges represent bonds. Each node and edge carries an array of features as inferred from the chemical structure of the molecule.
Return type: - bond_type ('order' or 'type') – If ‘order’, an edge attribute ‘order’ will be populated with
numeric values such as 1 for single bonds, 2 for double bonds, and
1.5 for aromatic bonds. If ‘type’, an attribute ‘type’ will be
populated with
-
static
has_unified_types
(graphs)[source]¶ Check if all graphs have the same set of nodal/edge features.
-
laplacian
¶ Get the graph Laplacian as a sparse matrix.
Returns: laplacian – The laplacian matrix, either weighted or unweighted depending on the original graph. Return type: sparse matrix
-
permute
(perm, inplace=False)[source]¶ Rearrange the node indices of a graph by a permutation array.
Parameters: - perm (sequence) – Array of permuted node indices
- inplace (boolean) – Whether to reorder the nodes in-place or to create a new graph.
Returns: permuted_graph – The original graph object (inplace=True) or a new one (inplace=False) with the nodes permuted.
Return type:
-
classmethod
unify_datatype
(graphs, inplace=False)[source]¶ Ensure that each attribute has the same data type across graphs.
Parameters: - graphs (list) – A list of graphs that have the same set of node and edge features. The types for each attribute will then be chosen to be the smallest scalar type that can safely hold all the values as found across the graphs.
- inplace (bool) – Whether or not to modify the graph features in-place.
Returns: If inplace is True, the graphs will be modified in-place and nothing will be returned. Otherwise, a new list of graphs with type-unified features will be returned.
Return type: None or list
Subpackages¶
- graphdot.codegen package
- graphdot.cpp package
- graphdot.cuda package
- graphdot.dataset package
- graphdot.experimental package
- graphdot.graph package
- graphdot.kernel package
- graphdot.linalg package
- graphdot.metric package
- graphdot.microkernel package
- Submodules
- graphdot.microkernel.additive module
- graphdot.microkernel.composite module
- graphdot.microkernel.convolution module
- graphdot.microkernel.dotproduct module
- graphdot.microkernel.kronecker_delta module
- graphdot.microkernel.product module
- graphdot.microkernel.rational_quadratic module
- graphdot.microkernel.square_exponential module
- graphdot.microkernel.tensor_product module
- Submodules
- graphdot.minipandas package
- graphdot.model package
- graphdot.util package