agx.TopologyIterator

class agx.TopologyIterator(node_counts, graph_type=None, graph_set='rxx', allowed_num_components=1, max_samples=None, graph_directory=None, verbose=True)[source]

Bases: object

Iterate over graphs.

Important

Warning: Currently, the order of node_counts has to have the building block with the most connections first!

Parameters:
  • node_counts (dict[NodeType, int]) – Dictionary of agx.NodeType and their count in the proposed graphs. Always put the building blocks with more functional groups first. Additionally, only mixtures of three distinct node types (in terms of connection counts) are implemented, and in the case of three components, all nodes connect to the node type with the most connections.

  • graph_type (str | None) – Name of the graph. If you do not need a custom graph, you can leave this as None and it will adhere to the current name convention (see available_graphs), which captures the count of each node type with certain number of connections. Following this name convention will allow you to use saved graphs, if not, you can make your own. Although it can be time consuming.

  • graph_set (str) – Set of graphs to use based on different algorithms or papers. Only the new rxx set are defined here.

  • allowed_num_components (int) – Allowed number of disconnected graph components. Usually 1 to generate complete graphs only.

  • max_samples (int | None) – When constructing graphs, there is some randomness in their order, although that order should be consistent, and only up-to max_samples are sampled. For very large numbers of components there is not guarantee all possible graphs will be explored.

  • graph_directory (Path | None) – Directory to check for and save graph jsons.

  • verbose (bool) – Whether to log outcomes.

Methods

count_graphs

Count completely connected graphs in iteration.

generate_graph_type

Get the graph type to match the new naming convention.

get_configurations

Get potential node configurations.

get_num_nodes

Get number of nodes.

get_vertex_prototypes

Get vertex prototypes.

is_type_possible

Return True if the graph is chemically possible.

yield_configured_codes

Get potential node configurations.

yield_graphs

Get constructed molecules from iteration.

Attributes

count_graphs()[source]

Count completely connected graphs in iteration.

Return type:

int

generate_graph_type()[source]

Get the graph type to match the new naming convention.

Return type:

str

get_configurations()[source]

Get potential node configurations.

Return type:

Sequence[Configuration]

get_num_nodes()[source]

Get number of nodes.

Return type:

int

get_vertex_prototypes()[source]

Get vertex prototypes.

Return type:

Sequence[Node]

is_type_possible()[source]

Return True if the graph is chemically possible.

Return type:

bool

yield_configured_codes()[source]

Get potential node configurations.

Return type:

Iterator[ConfiguredCode]

yield_graphs()[source]

Get constructed molecules from iteration.

Yields only graphs with the allowed number of components.

Return type:

Generator[TopologyCode]

allowed_num_components: int = 1
graph_directory: Path | None = None
graph_set: str = 'rxx'
graph_type: str | None = None
max_samples: int | None = None
node_counts: dict[NodeType, int]
verbose: bool = True