Package 'graphkernels'

Title: Graph Kernels
Description: A fast C++ implementation for computing various graph kernels including (1) simple kernels between vertex and/or edge label histograms, (2) graphlet kernels, (3) random walk kernels (popular baselines), and (4) the Weisfeiler-Lehman graph kernel (state-of-the-art).
Authors: Mahito Sugiyama [aut, cre], The development of the graphkernels open access software package was financially supported by the Horizon 2020/CDS-QUAMRI/634541 project. This support is gratefully acknowledged. [fnd]
Maintainer: Mahito Sugiyama <[email protected]>
License: GPL (>= 2)
Version: 1.6.1
Built: 2025-02-12 05:26:17 UTC
Source: https://github.com/cran/graphkernels

Help Index


Graph Kernels

Description

A fast C++ implementation for computing various graph kernels including (1) simple kernels between vertex and/or edge label histograms, (2) graphlet kernels, (3) random walk kernels (popular baselines), and (4) the Weisfeiler-Lehman graph kernel (state-of-the-art).

Details

This library provides the following graph kernels:

  • the linear kernel between vertex label histograms

  • the linear kernel between edge label histograms

  • the linear kernel between vertex-edge label histograms

  • the linear kernel combination vertex label histograms and vertex-edge label histograms

  • the Gaussian RBF kernel between vertex label histograms

  • the Gaussian RBF kernel between edge label histograms

  • the Gaussian RBF kernel between vertex-edge label histograms

  • the graphlet kernel

  • the kk-step random walk kernel

  • the geometric random walk kernel

  • the exponential random walk kernel

  • the shortest-path kernel

  • the Weisfeiler-Lehman subtree kernel

Given a list of igraph graphs, each function calculates the corresponding kernel (Gram) matrix.

Author(s)

Mahito Sugiyama

Maintainer: Mahito Sugiyama <[email protected]>

References

Borgwardt, K. M., Kriegel, H.-P.: Shortest-Path Kernels on Graphs, Proceedings of the 5th IEEE International Conference on Data Mining (ICDM'05), 74-81 (2005) https://ieeexplore.ieee.org/document/1565664/.

Debnath, A. K., Lopez de Compadre, R. L., Debnath, G., Shusterman, A. J., Hansch, C.: Structure-activity relationship of mutagenic aromatic and heteroaromatic nitro compounds. correlation with molecular orbital energies and hydrophobicity, Journal of Medicinal Chemistry, 34(2), 786-797 (1991) https://pubs.acs.org/doi/abs/10.1021/jm00106a046.

Gartner, T., Flach, P., Wrobel, S.: On graph kernels: Hardness results and efficient alternatives, Learning Theory and Kernel Machines (LNCS 2777), 129-143 (2003) https://link.springer.com/chapter/10.1007/978-3-540-45167-9_11.

Shervashidze, N., Schweitzer, P., van Leeuwen, E. J., Mehlhorn, K., Borgwardt, K. M.: Weisfeiler-Lehman Graph Kernels, Journal of Machine Learning Research, 12, 2359-2561 (2011) https://www.jmlr.org/papers/volume12/shervashidze11a/shervashidze11a.pdf.

Shervashidze, N., Vishwanathan, S. V. N., Petri, T., Mehlhorn, K., Borgwardt, K. M.: Efficient Graphlet Kernels for Large Graph Comparison, Proceedings of the 12th International Conference on Artificial Intelligence and Statistics (AISTATS), 5, 488-495 (2009) https://proceedings.mlr.press/v5/shervashidze09a.html.

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
KEH <- CalculateEdgeHistKernel(mutag)
  ## compute linear kernel between edge histograms
KWL <- CalculateWLKernel(mutag, 5)
  ## compute Weisfeiler-Lehman subtree kernel

Connected graphlet kernel

Description

This function calculates a kernel matrix of the graphlet kernel with connected graphlets KCGLK_{CGL} between unlabeled graphs.

Usage

CalculateConnectedGraphletKernel(G, par)

Arguments

G

a list of igraph graphs

par

the number kk of graphlet nodes (k=3k = 3, 4, or 5 is supported)

Value

a kernel matrix of the connected graphlet kernel KCGLK_{CGL}

Author(s)

Mahito Sugiyama

References

Shervashidze, N., Vishwanathan, S. V. N., Petri, T., Mehlhorn, K., Borgwardt, K. M.: Efficient Graphlet Kernels for Large Graph Comparison, Proceedings of the 12th International Conference on Artificial Intelligence and Statistics (AISTATS), 5, 488-495 (2009) https://proceedings.mlr.press/v5/shervashidze09a.html.

Examples

data(mutag)
K <- CalculateConnectedGraphletKernel(mutag, 4)

Gaussian RBF kernel between edge label histograms

Description

This function calculates a kernel matrix of the Gaussian RBF kernel KEH,GK_{EH,G} between edge label histograms.

Usage

CalculateEdgeHistGaussKernel(G, par)

Arguments

G

a list of igraph graphs

par

σ\sigma in the Gaussian RBF kernel

Value

a kernel matrix of the Gaussian RBF kernel KEH,GK_{EH,G} between edge label histograms

Author(s)

Mahito Sugiyama

References

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateEdgeHistGaussKernel(mutag, .1)

Linear kernel between edge label histograms

Description

This function calculates a kernel matrix of the linear kernel KEHK_{EH} between edge label histograms.

Usage

CalculateEdgeHistKernel(G)

Arguments

G

a list of igraph graphs

Value

a kernel matrix of the linear kernel KEHK_{EH} between edge label histograms

Author(s)

Mahito Sugiyama

References

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateEdgeHistKernel(mutag)

Exponential random walk kernel

Description

This function calculates a kernel matrix of the exponential random walk kernel KERK_{ER}.

Usage

CalculateExponentialRandomWalkKernel(G, par)

Arguments

G

a list of igraph graphs

par

a coefficient β\beta, with which the weight λk\lambda_k for each step kk is given as λk=βk/k!\lambda_k = \beta^k / k!

Value

a kernel matrix of the exponential random walk kernel KERK_{ER}

Author(s)

Mahito Sugiyama

References

Gartner, T., Flach, P., Wrobel, S.: On graph kernels: Hardness results and efficient alternatives, Learning Theory and Kernel Machines (LNCS 2777), 129-143 (2003) https://link.springer.com/chapter/10.1007/978-3-540-45167-9_11.

Examples

data(mutag)
K <- CalculateExponentialRandomWalkKernel(mutag[1:5], .1)

Geometric random walk kernel

Description

This function calculates a kernel matrix of the geometric random walk kernel KGRK_{GR}.

Usage

CalculateGeometricRandomWalkKernel(G, par)

Arguments

G

a list of igraph graphs

par

a coefficient λ\lambda, with which the weight λk\lambda_k for each step kk is given as λk=λk\lambda_k = \lambda^k

Value

a kernel matrix of the geometric random walk kernel KGRK_{GR}

Author(s)

Mahito Sugiyama

References

Gartner, T., Flach, P., Wrobel, S.: On graph kernels: Hardness results and efficient alternatives, Learning Theory and Kernel Machines (LNCS 2777), 129-143 (2003) https://link.springer.com/chapter/10.1007/978-3-540-45167-9_11.

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateGeometricRandomWalkKernel(mutag, .1)

Graphlet kernel

Description

This function calculates a kernel matrix of the graphlet kernel KGLK_{GL} between unlabeled graphs.

Usage

CalculateGraphletKernel(G, par)

Arguments

G

a list of igraph graphs

par

the number kk of graphlet nodes (k=3k = 3 or 4 is supported)

Value

a kernel matrix of the graphlet kernel KGLK_{GL}

Author(s)

Mahito Sugiyama

References

Shervashidze, N., Vishwanathan, S. V. N., Petri, T., Mehlhorn, K., Borgwardt, K. M.: Efficient Graphlet Kernels for Large Graph Comparison, Proceedings of the 12th International Conference on Artificial Intelligence and Statistics (AISTATS), 5, 488-495 (2009) https://proceedings.mlr.press/v5/shervashidze09a.html.

Examples

data(mutag)
K <- CalculateGraphletKernel(mutag, 4)

An C++ implementation of graphlet kernels

Description

This function calculates a graphlet kernel matrix.

Usage

CalculateGraphletKernelCpp(graph_adj_all, graph_adjlist_all, k, connected)

Arguments

graph_adj_all

a list of adjacency matrices

graph_adjlist_all

a list of adjacency lists

k

the number kk of graphlet nodes

connected

whether or not graphlets are conneceted

Value

a kernel matrix of the respective graphlet kernel

Author(s)

Mahito Sugiyama

References

Shervashidze, N., Vishwanathan, S. V. N., Petri, T., Mehlhorn, K., Borgwardt, K. M.: Efficient Graphlet Kernels for Large Graph Comparison, Proceedings of the 12th International Conference on Artificial Intelligence and Statistics (AISTATS), 5, 488-495 (2009) https://proceedings.mlr.press/v5/shervashidze09a.html.

Examples

data(mutag)
al.list <- as.list(rep(NA, length(mutag)))
for (i in 1:length(mutag)) { al.list[[i]] <- as_adj_list(mutag[[i]]) }
K <- CalculateGraphletKernelCpp(list(), al.list, 4, 0)

An C++ implementation of graph kernels

Description

This function calculates a kernel matrix.

Usage

CalculateKernelCpp(graph_info_list, par_r, kernel_type)

Arguments

graph_info_list

a list of igraph graphs

par_r

parameters of kernels

kernel_type

type of kernel

Value

a kernel matrix of the respective kernel

Author(s)

Mahito Sugiyama

References

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
graph.info.list <- vector("list", length(mutag))
for (i in 1:length(mutag)) { graph.info.list[[i]] <- GetGraphInfo(mutag[[i]]) }
K <- CalculateKernelCpp(graph.info.list, 5, 11)

k-step random walk kernel

Description

This function calculates a kernel matrix of the kk-step random walk kernel K×kK_{\times}^{k}.

Usage

CalculateKStepRandomWalkKernel(G, par)

Arguments

G

a list of igraph graphs

par

a vector of coefficients λ0,λ1,,λk\lambda_0, \lambda_1, \dots, \lambda_k

Value

a kernel matrix of the k-step random walk kernel K×kK_{\times}^{k}

Author(s)

Mahito Sugiyama

References

Gartner, T., Flach, P., Wrobel, S.: On graph kernels: Hardness results and efficient alternatives, Learning Theory and Kernel Machines (LNCS 2777), 129-143 (2003) https://link.springer.com/chapter/10.1007/978-3-540-45167-9_11.

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateKStepRandomWalkKernel(mutag, rep(1, 2))

Shortest-path kernel

Description

This function calculates a kernel matrix of the shortest-path kernel KSPK_{SP}.

Usage

CalculateShortestPathKernel(G)

Arguments

G

a list of igraph graphs

Value

a kernel matrix of the shortest-path kernel KSPK_{SP}

Author(s)

Mahito Sugiyama

References

Borgwardt, K. M., Kriegel, H.-P.: Shortest-Path Kernels on Graphs, Proceedings of the 5th IEEE International Conference on Data Mining (ICDM'05), 74-81 (2005) https://ieeexplore.ieee.org/document/1565664/.

Examples

data(mutag)
K <- CalculateShortestPathKernel(mutag)

Gaussian RBF kernel between vertex-edge label histograms

Description

This function calculates a kernel matrix of the Gaussian RBF kernel KVEH,GK_{VEH,G} between vertex-edge label histograms.

Usage

CalculateVertexEdgeHistGaussKernel(G, par)

Arguments

G

a list of igraph graphs

par

σ\sigma in the Gaussian RBF kernel

Value

a kernel matrix of the Gaussian RBF kernel KVEH,GK_{VEH,G} between vertex-edge label histograms

Author(s)

Mahito Sugiyama

References

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateVertexEdgeHistGaussKernel(mutag, .1)

Linear kernel between vertex-edge label histograms

Description

This function calculates a kernel matrix of the linear kernel KVEHK_{VEH} between vertex-edge label histograms.

Usage

CalculateVertexEdgeHistKernel(G)

Arguments

G

a list of igraph graphs

Value

a kernel matrix of the linear kernel KVEHK_{VEH} between vertex-edge label histograms

Author(s)

Mahito Sugiyama

References

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateVertexEdgeHistKernel(mutag)

Gaussian RBF kernel between vertex label histograms

Description

This function calculates a kernel matrix of the Gaussian RBF kernel KVH,GK_{VH,G} between vertex label histograms.

Usage

CalculateVertexHistGaussKernel(G, par)

Arguments

G

a list of igraph graphs

par

σ\sigma in the Gaussian RBF kernel

Value

a kernel matrix of the Gaussian RBF kernel KVH,GK_{VH,G} between vertex label histograms

Author(s)

Mahito Sugiyama

References

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateVertexHistGaussKernel(mutag, .1)

Linear kernel between vertex label histograms

Description

This function calculates a kernel matrix of the linear kernel KVHK_{VH} between vertex label histograms.

Usage

CalculateVertexHistKernel(G)

Arguments

G

a list of igraph graphs

Value

a kernel matrix of the linear kernel KVHK_{VH} between vertex label histograms

Author(s)

Mahito Sugiyama

References

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateVertexHistKernel(mutag)

Linear kernel combination of vertex label histograms and vertex-edge label histograms

Description

This function calculates a kernel matrix of the linear kernel combination KHK_{H} of vertex label histograms KVHK_{VH} and vertex-edge label histograms KVEHK_{VEH}.

Usage

CalculateVertexVertexEdgeHistKernel(G, par)

Arguments

G

a list of igraph graphs

par

a coefficient λ\lambda, with which the resulting kernel is given as KVH+λKVEHK_{VH} + \lambda K_{VEH}

Value

a kernel matrix that is equivalent to KVH+λKVEHK_{VH} + \lambda K_{VEH}

Author(s)

Mahito Sugiyama

References

Sugiyama, M., Borgwardt, K. M.: Halting in Random Walk Kernels, Advances in Neural Information Processing Systems (NIPS 2015), 28, 1630-1638 (2015) https://papers.nips.cc/paper/5688-halting-in-random-walk-kernels.pdf.

Examples

data(mutag)
K <- CalculateVertexVertexEdgeHistKernel(mutag, .1)

Weisfeiler-Lehman subtree kernel

Description

This function calculates a kernel matrix of the Weisfeiler-Lehman subtree kernel KWLK_{WL}.

Usage

CalculateWLKernel(G, par)

Arguments

G

a list of igraph graphs

par

the number hh of iterations

Value

a kernel matrix of the Weisfeiler-Lehman subtree kernel KWLK_{WL}

Author(s)

Mahito Sugiyama

References

Shervashidze, N., Schweitzer, P., van Leeuwen, E. J., Mehlhorn, K., Borgwardt, K. M.: Weisfeiler-Lehman Graph Kernels, Journal of Machine Learning Research, 12, 2359-2561 (2011) https://www.jmlr.org/papers/volume12/shervashidze11a/shervashidze11a.pdf.

Examples

data(mutag)
K <- CalculateWLKernel(mutag, 5)

Necessary information of graphs for kernel computation

Description

This function extracts necessary information of graphs for kernel computation.

Usage

GetGraphInfo(g)

Arguments

g

an igraph graph

Value

a list of graph information with the following elements:

edge

a matrix of edges with their labels

vlabel

a vector of vertex labels

vsize

the number of vertices

esize

the number of edges

maxdegree

the maximum degree

Author(s)

Mahito Sugiyama

Examples

data(mutag)
ginfo <- GetGraphInfo(mutag[[1]])

Symbol registration

Description

This is a supplement for symbol registration.

Author(s)

Mahito Sugiyama


Symbol registration

Description

This is a supplement for symbol registration.

Author(s)

Mahito Sugiyama


The mutag dataset

Description

This is the mutag dataset, a well known benchmark dataset for graph processing algorithms.

Usage

data(mutag)

Author(s)

Mahito Sugiyama

References

Debnath, A. K., Lopez de Compadre, R. L., Debnath, G., Shusterman, A. J., Hansch, C.: Structure-activity relationship of mutagenic aromatic and heteroaromatic nitro compounds. correlation with molecular orbital energies and hydrophobicity, Journal of Medicinal Chemistry, 34(2), 786-797 (1991) https://pubs.acs.org/doi/abs/10.1021/jm00106a046.

Examples

data(mutag)
K <- CalculateWLKernel(mutag, 5)