Skip to content

Commit

Permalink
fixes to check_specs
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0na committed May 25, 2020
1 parent 0b5e1ad commit ac494e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,7 +1,7 @@
Package: ghypernet
Type: Package
Title: Fit and Simulate Generalised Hypergeometric Ensembles of Graphs
Version: 1.0.0
Version: 1.0.0.9000
Date: 2020-05-11
Authors@R: c(
person("Giona", "Casiraghi", email = "giona@ethz.ch",
Expand Down
20 changes: 10 additions & 10 deletions R/auxilliary.R
Expand Up @@ -49,27 +49,27 @@ check_specs <- function(object, ...){

check_specs.matrix <- function(object, ...){
if(is.matrix(object)){
if(is.null(directed)){
# if(is.null(directed)){
if(isSymmetric(object)){
directed <- FALSE
} else{
directed <- TRUE
}
} else{
if(!directed & !isSymmetric(object)){
warning('Trying to compute undirected ensemble for asymmetric adjacency matrix.
Adjacency matrix symmetrised as adj <- adj + t(adj)')
object <- object + t(object)
}
}
# } else{
# if(!directed & !isSymmetric(object)){
# warning('Trying to compute undirected ensemble for asymmetric adjacency matrix.
# Adjacency matrix symmetrised as adj <- adj + t(adj)')
# object <- object + t(object)
# }
# }

if(is.null(selfloops)){
# if(is.null(selfloops)){
if(all(diag(object)==0)){
selfloops <- FALSE
} else{
selfloops <- TRUE
}
}
# }
}
return(c('directed'=directed, 'selfloops'=selfloops))
}
8 changes: 4 additions & 4 deletions R/igraphintegration.R
@@ -1,21 +1,21 @@
# auxiliary function for to extract igraph properties
check_specs.igraph <- function(object, ...){
if(requireNamespace("igraph", quietly = TRUE) && igraph::is.igraph(object)){
if(is.null(directed)){
# if(is.null(directed)){
if(igraph::is.directed(object)){
directed <- FALSE
} else{
directed <- TRUE
}
}
# }

if(is.null(selfloops)){
# if(is.null(selfloops)){
if(igraph::is.simple(igraph::simplify(object, remove.multiple = TRUE, remove.loops = FALSE))){
selfloops <- FALSE
} else{
selfloops <- TRUE
}
}
# }
}
return(c('directed'=directed, 'selfloops'=selfloops))
}
Expand Down

0 comments on commit ac494e0

Please sign in to comment.