Skip to content

Commit 9f6fdad

Browse files
authored
Merge pull request #90 from statnet/all-the-generics
Just make the rest of them generics.
2 parents ffe733f + 414ec61 commit 9f6fdad

9 files changed

Lines changed: 111 additions & 18 deletions

File tree

NAMESPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ S3method(get.edge.attribute,list)
3737
S3method(get.edge.attribute,network)
3838
S3method(get.edge.value,list)
3939
S3method(get.edge.value,network)
40+
S3method(get.edgeIDs,network)
41+
S3method(get.edges,network)
4042
S3method(get.inducedSubgraph,network)
43+
S3method(get.neighborhood,network)
4144
S3method(get.network.attribute,network)
4245
S3method(get.vertex.attribute,network)
46+
S3method(has.edges,network)
47+
S3method(is.adjacent,network)
4348
S3method(is.bipartite,mixingmatrix)
4449
S3method(is.bipartite,network)
4550
S3method(is.directed,mixingmatrix)
@@ -49,6 +54,7 @@ S3method(list.edge.attributes,network)
4954
S3method(list.network.attributes,network)
5055
S3method(list.vertex.attributes,network)
5156
S3method(mixingmatrix,network)
57+
S3method(network.density,network)
5258
S3method(network.dyadcount,network)
5359
S3method(network.edgecount,network)
5460
S3method(network.naedgecount,network)

R/access.R

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ get.edge.value.list <- get.edge.value.network
731731
#' @param na.omit logical; should we omit missing edges?
732732
#' @param tails a vector of vertex ID for the 'tails' (v) side of the dyad
733733
#' @param heads a vector of vertex ID for the 'heads' (alter) side of the dyad
734+
#' @param ... additional arguments to methods
734735
#' @return For \code{get.edges}, a list of edges. For \code{get.edgeIDs}, a
735736
#' vector of edge ID numbers. For \code{get.dyads.eids}, a list of edge IDs
736737
#' corresponding to the dyads defined by the vertex ids in \code{tails} and
@@ -752,7 +753,11 @@ get.edge.value.list <- get.edge.value.network
752753
#' get.edgeIDs(g,1,neighborhood="in")
753754
#'
754755
#' @export get.edgeIDs
755-
get.edgeIDs<-function(x, v, alter=NULL, neighborhood=c("out","in","combined"), na.omit=TRUE){
756+
get.edgeIDs <- function(x, v, alter=NULL, neighborhood=c("out","in","combined"), na.omit=TRUE, ...) UseMethod("get.edgeIDs")
757+
758+
#' @rdname get.edges
759+
#' @export
760+
get.edgeIDs.network <- function(x, v, alter=NULL, neighborhood=c("out","in","combined"), na.omit=TRUE, ...){
756761
#Check to be sure we were called with a network
757762
if(!is.network(x))
758763
stop("get.edgeIDs requires an argument of class network.")
@@ -780,7 +785,11 @@ get.edgeIDs<-function(x, v, alter=NULL, neighborhood=c("out","in","combined"), n
780785

781786
#' @rdname get.edges
782787
#' @export get.edges
783-
get.edges<-function(x, v, alter=NULL, neighborhood=c("out","in","combined"), na.omit=TRUE){
788+
get.edges <- function(x, v, alter=NULL, neighborhood=c("out","in","combined"), na.omit=TRUE, ...) UseMethod("get.edges")
789+
790+
#' @rdname get.edges
791+
#' @export
792+
get.edges.network <- function(x, v, alter=NULL, neighborhood=c("out","in","combined"), na.omit=TRUE, ...){
784793
#Check to be sure we were called with a network
785794
if(!is.network(x))
786795
stop("get.edges requires an argument of class network.")
@@ -803,7 +812,11 @@ get.edges<-function(x, v, alter=NULL, neighborhood=c("out","in","combined"), na.
803812
# as defined by a vector of tails and heads vertex ids
804813
#' @rdname get.edges
805814
#' @export get.dyads.eids
806-
get.dyads.eids<-function(x,tails,heads,neighborhood = c("out", "in", "combined"),na.omit = TRUE){
815+
get.dyads.eids <- function(x, tails, heads, neighborhood = c("out", "in", "combined"), na.omit = TRUE, ...) UseMethod("get.dyad.eids")
816+
817+
#' @rdname get.edges
818+
#' @export
819+
get.dyads.eids <- function(x, tails, heads, neighborhood = c("out", "in", "combined"), na.omit = TRUE, ...){
807820
if(length(tails)!=length(heads)){
808821
stop('heads and tails vectors must be the same length for get.dyads.eids')
809822
}
@@ -907,7 +920,7 @@ get.dyads.eids<-function(x,tails,heads,neighborhood = c("out", "in", "combined")
907920
#'
908921
#'
909922
#' @export get.inducedSubgraph
910-
get.inducedSubgraph <- function(x, ...) UseMethod("get.inducedSubgraph")
923+
get.inducedSubgraph <- function(x, v, alters=NULL,...) UseMethod("get.inducedSubgraph")
911924

912925
#' @rdname get.inducedSubgraph
913926
#' @export
@@ -1024,6 +1037,7 @@ get.network.attribute.network <- function(x, attrname, unlist=FALSE, ...) {
10241037
#' @param type the neighborhood to be computed
10251038
#' @param na.omit logical; should missing edges be ignored when obtaining
10261039
#' vertex neighborhoods?
1040+
#' @param ... additional arguments to methods
10271041
#' @return A vector containing the vertex IDs for the chosen neighborhood.
10281042
#' @author Carter T. Butts \email{buttsc@@uci.edu}
10291043
#' @seealso \code{\link{get.edges}}, \code{\link{is.adjacent}}
@@ -1047,7 +1061,11 @@ get.network.attribute.network <- function(x, attrname, unlist=FALSE, ...) {
10471061
#' get.neighborhood(g,1,"combined")
10481062
#'
10491063
#' @export get.neighborhood
1050-
get.neighborhood<-function(x, v, type=c("out","in","combined"), na.omit=TRUE){
1064+
get.neighborhood<-function(x, v, type=c("out","in","combined"), na.omit=TRUE, ...) UseMethod("get.neighborhood")
1065+
1066+
#' @rdname get.neighborhood
1067+
#' @export
1068+
get.neighborhood.network<-function(x, v, type=c("out","in","combined"), na.omit=TRUE, ...){
10511069
#Check to be sure we were called with a network
10521070
if(!is.network(x))
10531071
stop("get.neighborhood requires an argument of class network.")
@@ -1217,6 +1235,7 @@ has.loops<-function(x){
12171235
#' @param vj a second vertex ID
12181236
#' @param na.omit logical; should missing edges be ignored when assessing
12191237
#' adjacency?
1238+
#' @param ... additional arguments to methods
12201239
#' @return A logical, giving the status of the (i,j) edge
12211240
#' @note Prior to version 1.4, \code{na.omit} was set to \code{TRUE} by
12221241
#' default.
@@ -1241,7 +1260,11 @@ has.loops<-function(x){
12411260
#' g[2,1]==1 #FALSE
12421261
#'
12431262
#' @export is.adjacent
1244-
is.adjacent<-function(x,vi,vj,na.omit=FALSE){
1263+
is.adjacent <- function(x, vi, vj, na.omit=FALSE, ...) UseMethod("is.adjacent")
1264+
1265+
#' @rdname is.adjacent
1266+
#' @export
1267+
is.adjacent.network <- function(x, vi, vj, na.omit=FALSE, ...){
12451268
if(!is.network(x))
12461269
stop("is.adjacent requires an argument of class network.\n")
12471270
if(length(vi)!=length(vj)){

R/misc.R

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ print.mixingmatrix <- function(x, ...) {
344344
#' density?
345345
#' @param discount.bipartite logical; if \code{x} is bipartite, should
346346
#' \dQuote{forbidden} edges be excluded from the count of potential edges?
347+
#' @param ... additional arguments to methods
347348
#' @return The network density.
348349
#' @section Warning : \code{network.density} relies on network attributes (see
349350
#' \link{network.indicators}) to determine the properties of the underlying
@@ -370,7 +371,11 @@ print.mixingmatrix <- function(x, ...) {
370371
#'
371372
#' @rdname network.density
372373
#' @export network.density
373-
network.density<-function(x,na.omit=TRUE,discount.bipartite=FALSE){
374+
network.density <- function(x, na.omit=TRUE, discount.bipartite=FALSE, ...) UseMethod("network.density")
375+
376+
#' @rdname network.density
377+
#' @export
378+
network.density.network <- function(x, na.omit=TRUE, discount.bipartite=FALSE, ...){
374379
if(!is.network(x))
375380
stop("network.density requires a network object.")
376381
if(network.size(x)==0){
@@ -413,6 +418,7 @@ network.density<-function(x,na.omit=TRUE,discount.bipartite=FALSE){
413418
#' @aliases is.isolate
414419
#' @param net a \code{\link{network}} object to be queried
415420
#' @param v integer vector of vertex ids to check
421+
#' @param ... additional arguments to methods
416422
#' @return returns a logical vector with the same length as v, with TRUE if the
417423
#' vertex is involved in any edges, FALSE if it is an isolate.
418424
#' @author skyebend
@@ -425,7 +431,11 @@ network.density<-function(x,na.omit=TRUE,discount.bipartite=FALSE){
425431
#'
426432
#' @rdname has.edges
427433
#' @export has.edges
428-
has.edges<-function(net,v=seq_len(network.size(net))){
434+
has.edges <- function(net, v=seq_len(network.size(net)), ...) UseMethod("has.edges")
435+
436+
#' @rdname has.edges
437+
#' @export
438+
has.edges.network <- function(net, v=seq_len(network.size(net)), ...){
429439
if(network.size(net)==0){
430440
return(logical(0))
431441
}

man/get.edges.Rd

Lines changed: 37 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/get.inducedSubgraph.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/get.neighborhood.Rd

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/has.edges.Rd

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/is.adjacent.Rd

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/network.density.Rd

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)