network_generators

balanced_tree(height: int, branching_factor: int = 2, edge_sign: int = 1, loop_sign: int = 1) dict

Creates a balanced tree network of given height and branching_factor. All edges are either positive or negative, depending on edge_sign. The self-loop of the root component is either positive or negative, depending on loop_sign.

arguments:
  • height: height of tree

  • branching_factor: branching factor of tree

  • edge_sign: either 1 or -1 for positive or negative edges

  • loop_sign: either 1 or -1 for positive or negative self-loop of first component

returns:
  • primes: primes implicants

example:

>>> primes = balanced_tree(height=3)
cycle_graph(n: int, edge_sign: int = 1) dict

Creates a cycle network with n components. All edges are either positive or negative, depending on edge_sign.

arguments:
  • n: number of components

  • edge_sign: either 1 or -1 for positive or negative edges

returns:
  • primes: primes implicants

example:

>>> primes = cycle_graph(n=3)
path_graph(n: int, edge_sign: int = 1, loop_sign: int = 1) dict

Creates a path graph network with n nodes. All edges are either positive or negative, depending on edge_sign. The self-loop of the root component is either positive or negative, depending on loop_sign.

arguments:
  • n: number of components

  • edge_sign: either 1 or -1 for positive or negative edges

  • loop_sign: either 1 or -1 for positive or negative self-loop of root component

returns:
  • primes: primes implicants

example:

>>> primes = path_graph(n=3, edge_sign=-1, loop_sign=1)
random_boolean_expression(names: List[str], k: int, seed: int = 0) str

Creates a random Boolean expression by sampling k variables from names and filling a truth table randomly. The expression is guaranteed to be non-constant but it may effectivly be dependent by less than k variables.

arguments:
  • names (List[str]): components to sample from

  • k: inputs to the expression

  • seed: the seed of the randomizer

returns:
  • expression: random expression in bnet format

example:

>>> primes = random_boolean_expression(names=list("abcdefgh"), k=4)
random_regular_network(n: int, k: int, connector: str = 'and', edge_sign: int = 1, seed: int = 0) dict

Creates a random netowrk with n components each with a random truthtable of k inputs. The seed is used for the randomizer. Use 0 to generate a random seed.

arguments:
  • n: number of components

  • k: inputs of each truthtable

  • connector: either “and” or “or”

  • edge_sign: either 1 or -1 for positive or negative edges

  • seed: the seed of the randomizer

returns:
  • primes: primes implicants

example:

>>> primes = random_regular_network(n=3, k=2, connector="or")
random_truth_table_network(n: int, k: int, seed: int = 0) dict

Creates a random netowrk with n components each with a random truthtable of k inputs. The seed is used for the randomizer. Use 0 to generate a random seed.

arguments:
  • n: number of components

  • k: inputs of each truthtable

  • seed: the seed of the randomizer

returns:
  • primes: primes implicants

example:

>>> primes = random_truth_table_network(n=3, k=2)