linchemin.rem.graph_distance.graph_distance_factory

linchemin.rem.graph_distance.graph_distance_factory(syngraph1: MonopartiteReacSynGraph | BipartiteSynGraph, syngraph2: MonopartiteReacSynGraph | BipartiteSynGraph, ged_method: str, ged_params: dict | None = None) float[source]

To compute the graph edit distance between 2 SynGraph objects

Parameters:

syngraph1: Union[MonopartiteReacSynGraph, BipartiteSynGraph]

One of the input graphs

syngraph2: Union[MonopartiteReacSynGraph, BipartiteSynGraph]

Another input graph

ged_method: str

The graph edit distance algorithm to be used

ged_params: Union[dict, None]

It contains the optional parameters for chemical similarity calculations, which are: (i) reaction_fp: a string corresponding to the type of fingerprints to be used for reactions (ii) reaction_fp_params: a dictionary with the optional parameters for computing reaction fingerprints (iii) reaction_similarity_name: a string corresponding to the similarity type to be used for reactions (iv) molecular_fp: a string corresponding to the type of fingerprints to be used for molecules (v) molecular_fp_params: a dictionary with the optional parameters for computing molecular fingerprints (vi) molecular_fp_count_vect: a boolean indicating whether ‘GetCountFingerprint’ should be used (vii) molecular_similarity_name: a string corresponding to the similarity type to be used for molecules If it is not provided, the default parameters are used (default None)

Returns:

ged: float

The ged between the two input graphs

Example:

>>> graphs = json.loads(open('ibm_file.json').read())
>>> syngraphs = [translator('ibm_retro', g, 'syngraph', out_data_model='bipartite') for g in graphs]
>>> ged = graph_distance_factory(syngraphs[0], syngraphs[3], ged_method='nx_ged')