cotengra.pathfinders.path_kahypar

Contraction tree finders using kahypar hypergraph partitioning.

Attributes

Classes

PartitionTreeBuilder

Function wrapper that takes a function that partitions graphs and

Functions

get_hypergraph(inputs[, output, size_dict, accel])

Single entry-point for creating a, possibly accelerated, HyperGraph.

register_hyper_function(name, ssa_func, space[, constants])

Register a contraction path finder to be used by the hyper-optimizer.

get_rng([seed])

Get a source of random numbers.

get_kahypar_profile_dir()

to_sparse(hg[, weight_nodes, weight_edges])

kahypar_subgraph_find_membership(inputs, output, size_dict)

Module Contents

class cotengra.pathfinders.path_kahypar.PartitionTreeBuilder(partition_fn)[source]

Function wrapper that takes a function that partitions graphs and uses it to build a contraction tree. partition_fn should have signature:

def partition_fn(inputs, output, size_dict,

weight_nodes, weight_edges, **kwargs):

… return membership

Where weight_nodes and weight_edges decsribe how to weight the nodes and edges of the graph respectively and membership should be a list of integers of length len(inputs) labelling which partition each input node should be put it.

build_divide(inputs, output, size_dict, random_strength=0.01, cutoff=10, parts=2, parts_decay=0.5, sub_optimize='greedy', super_optimize='auto-hq', check=False, seed=None, **partition_opts)[source]
build_agglom(inputs, output, size_dict, random_strength=0.01, groupsize=4, check=False, sub_optimize='greedy', seed=None, **partition_opts)[source]
trial_fn(inputs, output, size_dict, **partition_opts)[source]
trial_fn_agglom(inputs, output, size_dict, **partition_opts)[source]
cotengra.pathfinders.path_kahypar.get_hypergraph(inputs, output=None, size_dict=None, accel=False)[source]

Single entry-point for creating a, possibly accelerated, HyperGraph.

cotengra.pathfinders.path_kahypar.register_hyper_function(name, ssa_func, space, constants=None)[source]

Register a contraction path finder to be used by the hyper-optimizer.

Parameters:
  • name (str) – The name to call the method.

  • ssa_func (callable) – The raw function that returns a ‘ContractionTree’, with signature (inputs, output, size_dict, **kwargs).

  • space (dict[str, dict]) – The space of hyper-parameters to search.

cotengra.pathfinders.path_kahypar.get_rng(seed=None)[source]

Get a source of random numbers.

Parameters:

seed (None or int or random.Random, optional) – The seed for the random number generator. If None, use the default random number generator. If an integer, use a new random number generator with the given seed. If a random.Random instance, use that instance.

cotengra.pathfinders.path_kahypar.get_kahypar_profile_dir()[source]
cotengra.pathfinders.path_kahypar.to_sparse(hg, weight_nodes='const', weight_edges='log')[source]
cotengra.pathfinders.path_kahypar.kahypar_subgraph_find_membership(inputs, output, size_dict, weight_nodes='const', weight_edges='log', fix_output_nodes=False, parts=2, imbalance=0.01, compress=0, seed=None, profile=None, mode='direct', objective='cut', quiet=True)[source]
cotengra.pathfinders.path_kahypar.kahypar_to_tree