Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: netrics
Title: Many Marks, Measures, Memberships, and Motifs for Networks
Version: 1.0.0
Version: 1.0.1
Description: Many tools for calculating network, node, or tie
marks, measures, motifs and memberships of many different types of networks.
Marks identify structural positions, measures quantify network properties,
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# netrics 1.0.1

## Methods

- Fixed `cluster_cosine()` to cluster nodes and not census features (thanks @Kaladani)

# netrics 1.0.0

## Package
Expand Down
2 changes: 1 addition & 1 deletion R/method_cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ cluster_hierarchical <- function(motif, distance){
#' and this is given to `stats::hclust` to enable dendrogram construction etc.
#' @export
cluster_cosine <- function(motif, distance){
cosines <- manynet::to_cosine(motif)
cosines <- manynet::to_cosine(t(motif))
dissimilarity <- 1 - cosines
distances <- stats::dist(dissimilarity, method = distance)
hc <- stats::hclust(distances)
Expand Down
12 changes: 11 additions & 1 deletion tests/testthat/test-model_cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ test_that("cluster_cosine works", {
expect_s3_class(cluster_cosine(node_x_triad(ison_monks), distance = "euclidean"), "hclust")
})

test_that("cluster_cosine works", {
test_that("cluster_cosine clusters nodes and not census features", {
# `ison_algebra` gives a 16 x 96 census,
# so a membership of the wrong length is visible here
expect_equal(length(node_in_structural(ison_algebra, cluster = "cosine")),
c(net_nodes(ison_algebra)))
expect_equal(nrow(as.matrix(cluster_cosine(node_x_tie(ison_algebra),
distance = "euclidean")$distances)),
c(net_nodes(ison_algebra)))
})

test_that("cluster_concor works", {
unlab_2mode <- generate_random(c(6,6))
expect_s3_class(cluster_concor(unlab_2mode, node_x_tetrad(unlab_2mode)), "hclust")
})
Loading