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
7 changes: 3 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Package: manynet
Title: Many Ways to Make, Modify, Mark, and Measure Myriad Networks
Version: 2.1.1
Description: Many tools for making, modifying, marking, measuring,
and motifs and memberships of many different types of networks.
Title: Many Ways to Make, Manipulate, and Modify Myriad Networks
Version: 2.1.2
Description: Many tools for making, manipulating, and modifying many different types of networks.
All functions operate with matrices, edge lists, and 'igraph', 'network', and 'tidygraph' objects,
on directed, multiplex, multimodal, signed, and other networks.
The package includes functions for importing and exporting, creating and generating networks,
Expand Down
59 changes: 4 additions & 55 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ S3method(as_tidygraph,siena)
S3method(as_tidygraph,stocnet)
S3method(as_tidygraph,tbl_graph)
S3method(bind_changes,default)
S3method(bind_changes,igraph)
S3method(bind_changes,stocnet)
S3method(bind_changes,tbl_graph)
S3method(bind_nodes,default)
Expand All @@ -142,6 +143,8 @@ S3method(filter_nodes,default)
S3method(filter_nodes,stocnet)
S3method(filter_nodes,tbl_graph)
S3method(filter_ties,default)
S3method(filter_ties,igraph)
S3method(filter_ties,stocnet)
S3method(filter_ties,tbl_graph)
S3method(from_ties,stocnet)
S3method(from_ties,tbl_graph)
Expand Down Expand Up @@ -394,6 +397,7 @@ S3method(to_components,matrix)
S3method(to_components,network)
S3method(to_components,tbl_graph)
S3method(to_correlation,default)
S3method(to_correlation,matrix)
S3method(to_correlation,tbl_graph)
S3method(to_cosine,default)
S3method(to_cosine,matrix)
Expand Down Expand Up @@ -776,51 +780,11 @@ export(node_heterophily)
export(node_hierarchy)
export(node_homophily)
export(node_hub)
export(node_in_adopter)
export(node_in_automorphic)
export(node_in_betweenness)
export(node_in_brokering)
export(node_in_community)
export(node_in_component)
export(node_in_core)
export(node_in_eigen)
export(node_in_equivalence)
export(node_in_fluid)
export(node_in_greedy)
export(node_in_infomap)
export(node_in_leiden)
export(node_in_louvain)
export(node_in_optimal)
export(node_in_partition)
export(node_in_regular)
export(node_in_roulette)
export(node_in_spinglass)
export(node_in_strong)
export(node_in_structural)
export(node_in_walktrap)
export(node_in_weak)
export(node_indegree)
export(node_induced)
export(node_infomap)
export(node_information)
export(node_is_core)
export(node_is_cutpoint)
export(node_is_exposed)
export(node_is_fold)
export(node_is_independent)
export(node_is_infected)
export(node_is_isolate)
export(node_is_latent)
export(node_is_max)
export(node_is_mean)
export(node_is_mentor)
export(node_is_min)
export(node_is_mode)
export(node_is_neighbor)
export(node_is_pendant)
export(node_is_random)
export(node_is_recovered)
export(node_is_universal)
export(node_kcoreness)
export(node_kernighanlin)
export(node_leading_eigen)
Expand Down Expand Up @@ -904,21 +868,6 @@ export(tie_closeness)
export(tie_cohesion)
export(tie_degree)
export(tie_eigenvector)
export(tie_is_bridge)
export(tie_is_cyclical)
export(tie_is_feedback)
export(tie_is_imbalanced)
export(tie_is_loop)
export(tie_is_max)
export(tie_is_min)
export(tie_is_multiple)
export(tie_is_path)
export(tie_is_random)
export(tie_is_reciprocated)
export(tie_is_simmelian)
export(tie_is_transitive)
export(tie_is_triangular)
export(tie_is_triplet)
export(tie_is_twomode)
export(tie_signs)
export(tie_weights)
Expand Down
30 changes: 30 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# manynet 2.1.2

## Package

- Updated title/description text
- Updated README
- Updated TOC to include new wrangling section
- Added package migration note to README
- Updated startup messages with migration notesand links to `{autograph}`, `{netrics}`, and `{migraph}`
- Removed a set of defunct wrappers for moved/retired functions

## Making

- Fixed reference formatting of DOI and citation text

## Coercion

- Improved `expect_nodes()`/`expect_ties()` and introduces internal active-context helpers
- Fixed `as_diffusion.igraph()` to derive diffusion events from changelists

## Manipulating

- Added `filter_ties.igraph()` and `filter_ties.stocnet()`
- Improved active context inference across `mutate_nodes.stocnet()`, `mutate_ties.stocnet()`, `filter_nodes.stocnet()`, and `filter_ties.stocnet()`
- Added `bind_changes.igraph()` and delegated 'tbl_graph' method to it

## Modifying

- Added `to_correlation.matrix()` S3 method

# manynet 2.1.1

## Package
Expand Down
10 changes: 10 additions & 0 deletions R/coerce_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,16 @@ as_diffusion.mnet <- function(.data, twomode = FALSE, events) {
#' @export
as_diffusion.igraph <- function(.data, twomode = FALSE, events) {
net <- as_tidygraph(.data)
if (missing(events)) {
events <- as_changelist(.data)
}
events <- events |>
dplyr::filter(var == "diffusion") |>
dplyr::transmute(
t = time,
nodes = node,
event = value
)
event <- NULL
sumchanges <- events |> dplyr::group_by(t) |>
dplyr::reframe(I_new = sum(event == "I"),
Expand Down
5 changes: 3 additions & 2 deletions R/make_generate.R
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ generate_smallworld <- function(n, p = 0.05, directed = FALSE, width = 2) {
#' Barabasi, Albert-Laszlo, and Reka Albert. 1999.
#' “Emergence of Scaling in Random Networks.”
#' _Science_ 286(5439):509–12.
#' \doi{10.1126/science.286.5439.509}.
#' \doi{10.1126/science.286.5439.509}
#' @examples
#' generate_scalefree(12, 0.25)
#' generate_scalefree(12, 1.25)
Expand Down Expand Up @@ -348,8 +348,9 @@ generate_scalefree <- function(n, p = 1, directed = FALSE) {
#' @references
#' ## On the forest-fire model
#' Leskovec, Jure, Jon Kleinberg, and Christos Faloutsos. 2007.
#' "\href{https://www.cs.cmu.edu/~jure/pubs/powergrowth-tkdd.pdf}{Graph evolution: Densification and shrinking diameters}".
#' "Graph evolution: Densification and shrinking diameters".
#' _ACM transactions on Knowledge Discovery from Data_, 1(1): 2-es.
#' \doi{10.1145/1217299.1217301}
#' @examples
#' generate_fire(10)
#' @export
Expand Down
7 changes: 6 additions & 1 deletion R/manip_changes.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ bind_changes.default <- function(.data, changes, var, ...){

#' @export
bind_changes.tbl_graph <- function(.data, changes, var, ...){
as_tidygraph(bind_changes.igraph(.data, changes, var, ...))
}

#' @export
bind_changes.igraph <- function(.data, changes, var, ...){
out <- .data
if(length(names(changes)) == 4){

Expand Down Expand Up @@ -139,7 +144,7 @@ bind_changes.tbl_graph <- function(.data, changes, var, ...){
}

igraph::graph_attr(out)$changes <- changes
as_tidygraph(out)
out
}

.check_changevars <- function(changes){
Expand Down
15 changes: 10 additions & 5 deletions R/manip_nodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ filter_nodes.tbl_graph <- function(.data, ..., .by = NULL){

#' @export
filter_nodes.stocnet <- function(.data, ..., .by = NULL){
if(is.null(.data$nodes) || nrow(.data$nodes) == 0) return(.data)
with_active_context(.data, "nodes", {
if(is.null(.data$nodes) || nrow(.data$nodes) == 0) return(.data)

node_df <- dplyr::mutate(.data$nodes, .orig_id = dplyr::row_number())
kept_nodes <- dplyr::filter(node_df, ..., .by = dplyr::all_of(.by))
Expand All @@ -134,6 +135,7 @@ filter_nodes.stocnet <- function(.data, ..., .by = NULL){

make_stocnet(nodes = out_nodes, ties = out_ties, changes = out_changes,
global = .data$global, info = .data$info)
})
}

#' @rdname manip_nodes_num
Expand Down Expand Up @@ -279,10 +281,13 @@ mutate_nodes.network <- function(.data, ...){

#' @export
mutate_nodes.stocnet <- function(.data, ...){
out <- .data
out$nodes <- out$nodes |>
dplyr::mutate(...)
out
with_active_context(.data, "nodes", {
if (is.null(.data$nodes) || nrow(.data$nodes) == 0) return(.data)
out <- .data
out$nodes <- out$nodes |>
dplyr::mutate(...)
out
})
Comment thread
jhollway marked this conversation as resolved.
}

#' @rdname manip_nodes_attr
Expand Down
29 changes: 25 additions & 4 deletions R/manip_ties.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,31 @@ filter_ties.default <- function(.data, ...){
as_input(.data, filter_ties, ...)
}

#' @export
filter_ties.igraph <- function(.data, ...){
as_tidygraph(.data) |> tidygraph::activate(edges) |>
tidygraph::filter(...) |>
tidygraph::activate(nodes) |>
as_igraph()
}
Comment thread
jhollway marked this conversation as resolved.

#' @export
filter_ties.tbl_graph <- function(.data, ...){
.data |> tidygraph::activate(edges) |>
dplyr::filter(...) |>
tidygraph::activate(nodes)
}

#' @export
filter_ties.stocnet <- function(.data, ...){
with_active_context(.data, "edges", {
if (is.null(.data$ties) || nrow(.data$ties) == 0) return(.data)
out <- .data
out$ties <- out$ties |> dplyr::filter(...)
out
})
}
Comment thread
jhollway marked this conversation as resolved.

# Manipulating ties attributes ####

#' Manipulating tie attributes
Expand Down Expand Up @@ -271,10 +289,13 @@ mutate_ties.tbl_graph <- function(.data, ...){

#' @export
mutate_ties.stocnet <- function(.data, ...){
out <- .data
out$ties <- out$ties |>
dplyr::mutate(...)
out
with_active_context(.data, "edges", {
if (is.null(.data$ties) || nrow(.data$ties) == 0) return(.data)
out <- .data
out$ties <- out$ties |>
dplyr::mutate(...)
out
})
Comment thread
jhollway marked this conversation as resolved.
}

#' @rdname manip_ties_attr
Expand Down
Loading
Loading