sample_geom_hypergraph {HyperG} | R Documentation |
Construct a hypergraph from a random collection of points.
Description
A hypergraph defined by the relationships amongst a set of points.
Usage
sample_geom_hypergraph(n, m, d = 2, X, Y, radius,method = "Euclidean",
thresh.method="leq", uniformly = FALSE)
plot_geom_hypergraph(h, pch = 20, cex = 3, col = "gray",
plotY = TRUE, plot.circles = plotY,
full.circles=TRUE,
lty = 2, lcol = "black", ...)
Arguments
n |
The number of points to generate (ignored if |
m |
The number of nodes in the hypergraph (ignored if |
d |
dimension of the points (ignored if both |
radius , uniformly |
see Description. |
X |
see Description. |
Y |
see Description. |
method |
method passed to |
thresh.method |
if this is 'leq' then hyper-edges are defined by whether the Y points are a distance less than or equal to the radius. If 'geq', then it is determined by greater than. Any other value will default to 'leq'. |
h |
a hypergraph generated by |
plotY |
logical. Whether to plot the |
pch , cex , col |
parameters controling the plotting of |
plot.circles , full.circles |
logical. Whether to plot the circles defining the hyper-edges.
If |
lty , lcol |
parameters controling the plotting of the circles. |
... |
parameters passed to |
Details
If either X
or Y
is missing, it is generated as a set of
d-dimensional points in the unit cube, n
points in X
,
m
points in Y
. If X
is given, then n
is ignored. Similary with Y
and m
. If both are given,
then d
is ignored. There is no checking that the provided X
and/or Y
matrices conform to the n,m,d
values given in the
call.
The inter-point distance matrix is computed using dist
as proxy::dist(Y,X,method=method)
.
If radius
is not provided, it is
chosen uniformly at random from the unique values of the distance matrix
if uniformly
is FALSE, and uniformly from between the minimum and
maximum distance if uniformly
is true. As a rule, one should not
let this function choose the radius, but the code will do so if you wish.
The matrix is then thresholded by the
radius, resulting in a binary matrix which is then used as the
mxn incidence matrix for the hypergraph.
Value
a hypergraph. Additionally, the defining vectors X
and Y
and the radius
are returned as named values of the hypergraph.
Note
If both X
and Y
are given, and R
is not given,
a random value for R
is chosen randomly from the unique inter-point
distances.
If all three of these variables are provided, the hypergraph is not random.
Author(s)
David J. Marchette dmarchette@gmail.com
See Also
dist
.
Examples
set.seed(235)
h <- sample_geom_hypergraph(100,20,radius=0.2)
set.seed(3519)
Y <- matrix(runif(20),ncol=2)
X <- do.call(rbind,
lapply(1:nrow(Y),function(i) cbind(rnorm(10,Y[i,1]),rnorm(10,Y[i,2]))))
h <- sample_geom_hypergraph(X=X,Y=Y,radius=0.2)