Skip to contents

Returns the node coordinates computed by hypernets' existing hypergraph spectral or symmetric-NMF engine without exposing the incidental k-means assignments produced by hg_cluster().

Usage

hg_embed(
  hg,
  dimensions = 2L,
  type = c("zhou", "random_walk"),
  method = c("spectral", "symnmf"),
  seed = NULL,
  nstart = 25L,
  max_iter = 500L,
  tol = 1e-06
)

Arguments

hg

Any hypernets net_hg.

dimensions

Number of embedding coordinates, between 2 and n_nodes - 1.

type

Laplacian type: "zhou" or "random_walk".

method

"spectral" (default) or Hayashi et al.'s "symnmf". SymNMF requires a dense incidence matrix.

seed

Optional initialization seed.

nstart

Number of k-means starts for the shared engine; for spectral embeddings this affects only the discarded cluster assignment, not the returned coordinates. For SymNMF it is the number of factor restarts.

max_iter, tol

SymNMF iteration controls.

Value

A data frame with node, stationary mass pi, and dim1 through dim<dimensions>.

References

Zhou, D., Huang, J., & Schölkopf, B. (2006). Learning with hypergraphs: clustering, classification, and embedding. Advances in Neural Information Processing Systems 19.

Hayashi, K., Aksoy, S. G., Park, C. H., & Park, H. (2020). Hypergraph random walks, Laplacians, and clustering. Proceedings of the 29th ACM International Conference on Information and Knowledge Management, 495-504. doi:10.1145/3340531.3412034

Examples

h <- group_hypergraph(
  data.frame(node = c("a", "b", "c", "b", "c", "d"),
             edge = rep(c("e1", "e2"), each = 3)),
  "node", "edge"
)
hg_embed(h, dimensions = 2)
#>   node        pi dim1          dim2
#> 1    a 0.1666667 -0.5 -8.660254e-01
#> 2    b 0.3333333 -1.0  8.570850e-16
#> 3    c 0.3333333 -1.0  5.851370e-16
#> 4    d 0.1666667 -0.5  8.660254e-01