Compute the neighbors within the same class for a class_graph object.
Arguments
- x
A class_graph object.
- X
The data matrix corresponding to the graph nodes.
- k
The number of nearest neighbors to find.
- weight_mode
Method for weighting edges (e.g., "heat", "binary", "euclidean").
- sigma
Scaling factor for heat kernel if `weight_mode="heat"`.
- ...
Additional arguments passed to weight function.
Examples
labs <- factor(c("a","a","b","b"))
cg <- class_graph(labs)
X <- matrix(rnorm(8), ncol=2)
homogeneous_neighbors(cg, X, k=1)
#> $G
#> IGRAPH f1e3d7e U-W- 4 2 --
#> + attr: weight (e/n)
#> + edges from f1e3d7e:
#> [1] 1--2 3--4
#>
#> $params
#> $params$weight_mode
#> [1] "heat"
#>
#> $params$neighbor_mode
#> [1] "homogeneous"
#>
#> $params$k
#> [1] 1
#>
#> $params$sigma
#> [1] 1
#>
#>
#> attr(,"class")
#> [1] "neighbor_graph"