knn_hypergraph {HyperG} | R Documentation |
K-Nearest Neighbor Hypergraph.
Description
A hypergraph is constructed from data in which each hyper-edge corresponds to a vertex and its k-nearest neighbors.
Usage
knn_hypergraph(x, k = 1, method = "Euclidean", reduce=FALSE,
as.graph=FALSE)
Arguments
x |
a matrix of data points. |
k |
the number of neighbors. May be a vector. |
method |
distance type passed to |
reduce |
logical. Whether to remove redundant hyper-edges. |
as.graph |
logical. Whether to return a graph instead of a hypergraph. |
Details
Each vertex is in one-to-one correspondence with the points (rows)
of x
.
For each vertex, the k-closest vertices and itself form a hyper-edge.
If reduce=TRUE
reduntant hyper-edges (those contained in other
hyper-edges) are removed. If as.graph=TRUE
, reduce
is
ignored and the incidence matrix is treated as an adjacency matrix,
returning a (directed) igraph graph.
Value
a hypergraph or graph.
Author(s)
David J. Marchette dmarchette@gmail.com
See Also
Examples
set.seed(565)
x <- matrix(rnorm(100),ncol=2)
k <- knn_hypergraph(x,k=4)
plot(k)
plot(k,layout=x)