gklearn.kernels.structuralspKernel

Created on Thu Sep 27 10:56:23 2018

@author: linlin

@references:

[1] Suard F, Rakotomamonjy A, Bensrhair A. Kernel on Bag of Paths For Measuring Similarity of Shapes. InESANN 2007 Apr 25 (pp. 355-360).

getAllEdgeKernels(g1, g2, edge_kernels, edge_label, ds_attrs)[source]
getAllNodeKernels(g1, g2, node_kernels, node_label, ds_attrs)[source]
get_shortest_paths(G, weight, directed)[source]

Get all shortest paths of a graph.

Parameters

GNetworkX graphs

The graphs whose paths are computed.

weightstring/None

edge attribute used as weight to compute the shortest path.

directed: boolean

Whether graph is directed.

Return

splist of list

List of shortest paths of the graph, where each path is represented by a list of nodes.

get_sps_as_trie(G, weight, directed)[source]

Get all shortest paths of a graph and insert them into a trie.

Parameters

GNetworkX graphs

The graphs whose paths are computed.

weightstring/None

edge attribute used as weight to compute the shortest path.

directed: boolean

Whether graph is directed.

Return

splist of list

List of shortest paths of the graph, where each path is represented by a list of nodes.

ssp_do_trie(g1, g2, trie1, trie2, ds_attrs, node_label, edge_label, node_kernels, edge_kernels)[source]
structuralspkernel(*args, node_label='atom', edge_weight=None, edge_label='bond_type', node_kernels=None, edge_kernels=None, compute_method='naive', parallel='imap_unordered', n_jobs=None, chunksize=None, verbose=True)[source]

Compute mean average structural shortest path kernels between graphs.

Parameters

GnList of NetworkX graph

List of graphs between which the kernels are computed.

G1, G2NetworkX graphs

Two graphs between which the kernel is computed.

node_labelstring

Node attribute used as label. The default node label is atom.

edge_weightstring

Edge attribute name corresponding to the edge weight. Applied for the computation of the shortest paths.

edge_labelstring

Edge attribute used as label. The default edge label is bond_type.

node_kernelsdict

A dictionary of kernel functions for nodes, including 3 items: ‘symb’ for symbolic node labels, ‘nsymb’ for non-symbolic node labels, ‘mix’ for both labels. The first 2 functions take two node labels as parameters, and the ‘mix’ function takes 4 parameters, a symbolic and a non-symbolic label for each the two nodes. Each label is in form of 2-D dimension array (n_samples, n_features). Each function returns a number as the kernel value. Ignored when nodes are unlabeled.

edge_kernelsdict

A dictionary of kernel functions for edges, including 3 items: ‘symb’ for symbolic edge labels, ‘nsymb’ for non-symbolic edge labels, ‘mix’ for both labels. The first 2 functions take two edge labels as parameters, and the ‘mix’ function takes 4 parameters, a symbolic and a non-symbolic label for each the two edges. Each label is in form of 2-D dimension array (n_samples, n_features). Each function returns a number as the kernel value. Ignored when edges are unlabeled.

compute_methodstring

Computation method to store the shortest paths and compute the graph kernel. The Following choices are available:

‘trie’: store paths as tries.

‘naive’: store paths to lists.

n_jobsint

Number of jobs for parallelization.

Return

KmatrixNumpy matrix

Kernel matrix, each element of which is the mean average structural shortest path kernel between 2 praphs.

structuralspkernel_do(g1, g2, spl1, spl2, ds_attrs, node_label, edge_label, node_kernels, edge_kernels)[source]
traverseBothTriee(root, trie2, kernel, vk_dict, ek_dict, pcurrent=[])[source]
traverseBothTriem(root, trie2, kernel, vk_dict, ek_dict, pcurrent=[])[source]
traverseBothTrieu(root, trie2, kernel, vk_dict, ek_dict, pcurrent=[])[source]
traverseBothTriev(root, trie2, kernel, vk_dict, ek_dict, pcurrent=[])[source]
traverseTrie2e(root, p1, kernel, vk_dict, ek_dict, pcurrent=[])[source]
traverseTrie2m(root, p1, kernel, vk_dict, ek_dict, pcurrent=[])[source]
traverseTrie2u(root, p1, kernel, vk_dict, ek_dict, pcurrent=[])[source]
traverseTrie2v(root, p1, kernel, vk_dict, ek_dict, pcurrent=[])[source]
wrapper_getSP_naive(weight, directed, itr_item)[source]
wrapper_getSP_trie(weight, directed, itr_item)[source]
wrapper_ssp_do(ds_attrs, node_label, edge_label, node_kernels, edge_kernels, itr)[source]
wrapper_ssp_do_trie(ds_attrs, node_label, edge_label, node_kernels, edge_kernels, itr)[source]