spyrmsd.graphs.gt module

spyrmsd.graphs.gt.cycle(n)[source]

Build cycle graph

Parameters

n (int) – Number of nodes

Returns

Cycle graph

Return type

Graph

spyrmsd.graphs.gt.graph_from_adjacency_matrix(adjacency_matrix: Union[ndarray, List[List[int]]], aprops: Optional[Union[ndarray, List[Any]]] = None)[source]

Graph from adjacency matrix.

Parameters
  • adjacency_matrix (Union[np.ndarray, List[List[int]]]) – Adjacency matrix

  • aprops (Union[np.ndarray, List[Any]], optional) – Atomic properties

Returns

Molecular graph

Return type

Graph

Notes

It the atomic numbers are passed, they are used as node attributes.

spyrmsd.graphs.gt.lattice(n1: int, n2: int)[source]

Build 2D lattice graph

Parameters
  • n1 (int) – Number of nodes in dimension 1

  • n2 (int) – Number of nodes in dimension 2

Returns

Lattice graph

Return type

Graph

spyrmsd.graphs.gt.match_graphs(G1, G2) List[Tuple[List[int], List[int]]][source]

Compute graph isomorphisms.

Parameters
  • G1 – Graph 1

  • G2 – Graph 2

Returns

All possible mappings between nodes of graph 1 and graph 2 (isomorphisms)

Return type

List[Tuple[List[int],List[int]]]

Raises

NonIsomorphicGraphs – If the graphs G1 and G2 are not isomorphic

spyrmsd.graphs.gt.num_edges(G) int[source]

Number of edges

Parameters

G – Graph

Returns

Number of edges

Return type

int

spyrmsd.graphs.gt.num_vertices(G) int[source]

Number of vertices

Parameters

G – Graph

Returns

Number of vertices (nodes)

Return type

int

spyrmsd.graphs.gt.vertex_property(G, vproperty: str, idx: int) Any[source]

Get vertex (node) property from graph

Parameters
  • G – Graph

  • vproperty (str) – Vertex property name

  • idx (int) – Vertex index

Returns

Vertex property value

Return type

Any