module documentation

This Python module defines several factory functions for constructing graph generator functions. These generators implement various mechanisms for producing batches of fully colored k-edge-colored looped complete graphs of a specified batch size.

Function create_choose_two_graph_generator This function creates a GraphGenerator function that outputs batches of fully colored k-edge-colored looped complete graphs, where each graph in the batch is assigned to be equal to either one of two user-provided graphs according to a given probability...
Function create_edge_perturbation_graph_generator This function creates a GraphGenerator function that outputs batches of fully colored k-edge-colored looped complete graphs where all graphs are initially equal to a provided graph, and then each edge (resp...
Function create_fixed_graph_generator This function creates a GraphGenerator function that outputs batches of fully colored k-edge-colored looped complete graphs, where all the graphs are identical to a user-provided fixed_graph. The user can also configure the starting graph format of the output batch.
Function create_random_graph_generator This function creates a GraphGenerator function that outputs batches of fully colored k-edge-colored looped complete graphs generated randomly. Each edge (resp. arc) in each graph is assigned a color independently according to a specified discrete probability distribution...
Type Alias GraphGenerator This is a type alias for representing graph generator functions that accept a single int argument specifying the batch size and return a Graph object representing a batch of fully colored k-edge-colored looped complete graphs of that size...
def create_choose_two_graph_generator(first_graph: Graph, second_graph: Graph, second_graph_probability: float, graph_format: GraphFormat = GraphFormat.FLATTENED_ROW_MAJOR_COLORS, random_generator: np.random.Generator | None = None) -> GraphGenerator:

This function creates a GraphGenerator function that outputs batches of fully colored k-edge-colored looped complete graphs, where each graph in the batch is assigned to be equal to either one of two user-provided graphs according to a given probability. The two graphs must have the same number of edge colors, the same order, and the same type (both directed or both undirected, and both either allow loops or not). The user can also configure the starting graph format for the output batch.

Parameters
first_graph:GraphA fully colored Graph object representing the first graph that the output batch graphs could be equal to.
second_graph:GraphA fully colored Graph object representing the second graph that the output batch graphs could be equal to.
second_graph_probability:floatA float in the interval [0, 1] specifying the probability that a graph in the output batch is equal to second_graph.
graph_format:GraphFormatAn item of the GraphFormat enumeration specifying the format in which the output batch of graphs should be initialized. The default value is GraphFormat.FLATTENED_ROW_MAJOR_COLORS, i.e., the flattened row-major format with color numbers.
random_generator:np.random.Generator | NoneEither None, or a numpy.random.Generator used for probabilistic decisions. If None, a default generator will be used. The default value is None.
Returns
GraphGeneratorThe created GraphGenerator function.
def create_edge_perturbation_graph_generator(initial_graph: Graph, edge_perturbation_probability: float, color_selection_probabilities: np.ndarray | float | None = None, flattened_ordering: FlattenedOrdering = FlattenedOrdering.ROW_MAJOR, random_generator: np.random.Generator | None = None) -> GraphGenerator:

This function creates a GraphGenerator function that outputs batches of fully colored k-edge-colored looped complete graphs where all graphs are initially equal to a provided graph, and then each edge (resp. arc) may be perturbed with a given probability. The edge (resp. arc) perturbation consists of recoloring it with a randomly chosen color between 0 and k - 1 according to a discrete probability distribution. Here, k is determined from the provided initial graph. The output batch is initialized in one of the two flattened formats with color numbers, which can be selected via the flattened_ordering argument.

Parameters
initial_graph:GraphA fully colored Graph object representing the base graph that all graphs in the output batch are initialized to before edge (resp. arc) perturbations.
edge_perturbation_probability:floatA float from the interval [0, 1] specifying the probability that any given edge (resp. arc) is subjected to a perturbation.
color_selection_probabilities:np.ndarray | float | None

This argument defines how the new color for a perturbed edge (resp. arc) is chosen. Three options are allowed:

  1. A numpy.ndarray of length equal to the number of proper edge colors in initial_graph. The entries must be nonnegative and sum to 1. Each entry represents the probability of selecting the corresponding color (in ascending order).
  2. A single float (only if initial_graph has exactly two proper edge colors) representing the probability of selecting color 1; color 0 is chosen with complementary probability.
  3. None (the default), which selects the new color uniformly at random from all possible colors.
flattened_ordering:FlattenedOrderingAn item of the FlattenedOrdering enumeration specifying whether the output batch should be initialized in the flattened row-major or flattened clockwise format with color numbers. The default value is FlattenedOrdering.ROW_MAJOR.
random_generator:np.random.Generator | NoneEither None, or a numpy.random.Generator used for probabilistic decisions. If None, a default generator will be used. The default value is None.
Returns
GraphGeneratorThe created GraphGenerator function.
def create_fixed_graph_generator(fixed_graph: Graph, graph_format: GraphFormat = GraphFormat.FLATTENED_ROW_MAJOR_COLORS) -> GraphGenerator:

This function creates a GraphGenerator function that outputs batches of fully colored k-edge-colored looped complete graphs, where all the graphs are identical to a user-provided fixed_graph. The user can also configure the starting graph format of the output batch.

Parameters
fixed_graph:GraphA fully colored Graph object that all graphs in the output batch should be identical to.
graph_format:GraphFormatAn item of the GraphFormat enumeration specifying the format in which the output batch of graphs should be initialized. The default value is GraphFormat.FLATTENED_ROW_MAJOR_COLORS, i.e., the flattened row-major format with color numbers.
Returns
GraphGeneratorThe created GraphGenerator function.
def create_random_graph_generator(graph_order: int, color_selection_probabilities: np.ndarray | float | None = None, flattened_ordering: FlattenedOrdering = FlattenedOrdering.ROW_MAJOR, edge_colors: int = 2, is_directed: bool = False, allow_loops: bool = False, random_generator: np.random.Generator | None = None) -> GraphGenerator:

This function creates a GraphGenerator function that outputs batches of fully colored k-edge-colored looped complete graphs generated randomly. Each edge (resp. arc) in each graph is assigned a color independently according to a specified discrete probability distribution. The user can configure the graph order, number of proper edge colors, directionality, and loop allowance. The output batch is initialized in one of the two flattened formats with color numbers, which can be selected via the flattened_ordering argument.

Parameters
graph_order:intA positive int specifying the order of the graphs to be generated.
color_selection_probabilities:np.ndarray | float | None

This argument specifies the probability distribution for assigning a color to each edge (resp. arc). Three options are allowed:

  1. A numpy.ndarray of length equal to the number of proper edge colors in initial_graph. The entries must be nonnegative and sum to 1. Each entry represents the probability of selecting the corresponding color (in ascending order).
  2. A single float (only if initial_graph has exactly two proper edge colors) representing the probability of selecting color 1; color 0 is chosen with complementary probability.
  3. None (the default), which selects the new color uniformly at random from all possible colors.
flattened_ordering:FlattenedOrderingAn item of the FlattenedOrdering enumeration specifying whether the output batch should be initialized in the flattened row-major or flattened clockwise format with color numbers. The default value is FlattenedOrdering.ROW_MAJOR.
edge_colors:intA positive int (not below 2) specifying the number of proper edge colors in the graphs to be generated. The default value is 2.
is_directed:boolA bool indicating whether the graphs to be generated are directed. The default value is False.
allow_loops:boolA bool indicating whether loops are allowed in the graphs to be generated. The default value is False.
random_generator:np.random.Generator | NoneEither None, or a numpy.random.Generator used for probabilistic decisions. If None, a default generator will be used. The default value is None.
Returns
GraphGeneratorThe created GraphGenerator function.
GraphGenerator =

This is a type alias for representing graph generator functions that accept a single int argument specifying the batch size and return a Graph object representing a batch of fully colored k-edge-colored looped complete graphs of that size. The graphs in the batch are generated using an internal mechanism defined by the generator function, and the generation process need not be deterministic.

Value
Callable[[int], Graph]