fastwlk package

Submodules

fastwlk.kernel module

class fastwlk.kernel.WeisfeilerLehmanKernel(n_jobs: int = 4, precomputed: bool = False, n_iter: int = 3, node_label: str = 'residue', normalize: bool = False, biased: bool = False, verbose: bool = False)[source]

Bases: object

Weisfeiler-Lehmann kernel

compute_gram_matrix(X: List[networkx.classes.graph.Graph], Y: Optional[List[networkx.classes.graph.Graph]] = None) numpy.ndarray[source]

Computes the Gram matrix of the Weisfeiler-Lehman kernel.

Args:

X (List[nx.Graph]): List of graphs to use in the kernel. Y (Union[List[nx.Graph], None], optional): List of graphs to use in the kernel. Defaults to None.

Returns:

np.ndarray: _description_

compute_wl_hashes(G: networkx.classes.graph.Graph) Dict[source]

Computes Weisfeiler-Lehman hash histogram

Args:

G (nx.Graph): graph to compte the histogram of

node_label (str): node label to use as the starting node label of the

Weisfeiler-Lehman hashing process

n_iter (int): number of iterations of the Weisfeiler-Lehman algorithm

to run

Returns:

Dict: dictionary of the format {hash_value: n_nodes}.

diagonal(X, Y, K)[source]
dot_product(dicts: Tuple) int[source]

Computes the inner product of two dictionaries using common keys. This dramatically improves computation times when the number of keys is large but the overlap between the two dictionaries in the tuple is low.

Args:

dicts (Tuple): pair of dictionaries to compute the kernel from.

Returns:

int: dot product value of dicts

parallel_dot_product(lst: Iterable) Iterable[source]

Computes the inner product of elements in lst.

Args:

lst (Iterable): Iterable to compute the inner product of.

Returns:

Iterable: computed inner products.

Module contents

Top-level package for FastWLK.