From 33145a539516d2eaadf87fd5e04cdbc1ce147f70 Mon Sep 17 00:00:00 2001 From: "Pavel N. Krivitsky" Date: Tue, 2 Apr 2024 09:44:17 +1100 Subject: [PATCH] Made get.inducedSubgraph() generic. fixes statnet/network#86 --- NAMESPACE | 1 + R/access.R | 10 +++++++++- man/get.inducedSubgraph.Rd | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 713e4f5..360b1da 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,6 +37,7 @@ S3method(get.edge.attribute,list) S3method(get.edge.attribute,network) S3method(get.edge.value,list) S3method(get.edge.value,network) +S3method(get.inducedSubgraph,network) S3method(get.network.attribute,network) S3method(get.vertex.attribute,network) S3method(is.bipartite,mixingmatrix) diff --git a/R/access.R b/R/access.R index 9ba888c..237d805 100644 --- a/R/access.R +++ b/R/access.R @@ -906,6 +906,8 @@ get.dyads.eids<-function(x,tails,heads,neighborhood = c("out", "in", "combined") #' @param eid optionally, a numeric vector of valid edge ids in \code{x} that #' should be retained (cannot be used with \code{v} or \code{alter}) #' +#' @param ... additional arguments for methods. +#' #' @return A \code{\link{network}} object containing the induced subgraph. #' @author Carter T. Butts \email{buttsc@@uci.edu} #' @seealso \code{\link{network}}, \code{\link{network.extraction}} @@ -936,7 +938,13 @@ get.dyads.eids<-function(x,tails,heads,neighborhood = c("out", "in", "combined") #' #' #' @export get.inducedSubgraph -get.inducedSubgraph<-function(x, v, alters=NULL, eid=NULL){ +get.inducedSubgraph <- function(x, ...) { + UseMethod("get.inducedSubgraph") +} + +#' @rdname get.inducedSubgraph +#' @export +get.inducedSubgraph.network <- function(x, v, alters=NULL, eid=NULL, ...){ #Check to be sure we were called with a network if(!is.network(x)) stop("get.inducedSubgraph requires an argument of class network.") diff --git a/man/get.inducedSubgraph.Rd b/man/get.inducedSubgraph.Rd index f4fdb25..9a8ca77 100644 --- a/man/get.inducedSubgraph.Rd +++ b/man/get.inducedSubgraph.Rd @@ -2,16 +2,21 @@ % Please edit documentation in R/access.R, R/operators.R \name{get.inducedSubgraph} \alias{get.inducedSubgraph} +\alias{get.inducedSubgraph.network} \alias{\%s\%} \title{Retrieve Induced Subgraphs and Cuts} \usage{ -get.inducedSubgraph(x, v, alters = NULL, eid = NULL) +get.inducedSubgraph(x, ...) + +\method{get.inducedSubgraph}{network}(x, v, alters = NULL, eid = NULL, ...) x \%s\% v } \arguments{ \item{x}{an object of class \code{network}.} +\item{...}{additional arguments for methods.} + \item{v}{a vector of vertex IDs, or, for \code{\%s\%}, optionally a list containing two disjoint vectors of vertex IDs (see below).} \item{alters}{optionally, a second vector of vertex IDs. Must be disjoint