Skip to content

Commit

Permalink
suggest not import igraph
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Oct 17, 2019
1 parent df2978d commit 9db1016
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dodgr
Title: Distances on Directed Graphs
Version: 0.2.5.009
Version: 0.2.5.010
Authors@R: c(
person("Mark", "Padgham", email="[email protected]", role=c("aut", "cre")),
person("Andreas", "Petutschnig", role="aut"),
Expand All @@ -21,7 +21,6 @@ License: GPL-3
Imports:
callr,
digest,
igraph,
magrittr,
methods,
osmdata,
Expand All @@ -31,6 +30,7 @@ Suggests:
dplyr,
geodist,
ggplot2,
igraph,
igraphdata,
jsonlite,
knitr,
Expand Down
5 changes: 5 additions & 0 deletions R/centrality.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
#' graph <- dodgr_contract_graph (graph_full)
#' graph <- dodgr_centrality (graph)
#' # 'graph' is then the contracted graph with an additional 'centrality' column
#' # Same calculation via 'igraph':
#' igr <- dodgr_to_igraph (graph)
#' library (igraph)
#' cent <- edge_betweenness (igr)
#' identical (cent, graph$centrality) # TRUE
#' # Values of centrality between all junctions in the contracted graph can then
#' # be mapped back onto the original full network by "uncontracting":
#' graph_full <- dodgr_uncontract_graph (graph)
Expand Down
1 change: 1 addition & 0 deletions R/compare-heaps.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
compare_heaps <- function(graph, nverts = 100, replications = 2)
{
requireNamespace ("rbenchmark")
requireNamespace ("igraph")

if (is.numeric (nverts))
graph <- dodgr_sample (graph, nverts = nverts)
Expand Down
7 changes: 4 additions & 3 deletions R/graph-conversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ dodgr_to_sfc <- function (graph)
#' graphi <- dodgr_to_igraph (graph)
dodgr_to_igraph <- function (graph, weight_column = "d")
{
requireNamespace ("igraph")
graph <- tbl_to_df (graph)
if (!weight_column %in% names (graph))
stop ("graph contains no column named '", weight_column, "'")
Expand Down Expand Up @@ -161,6 +162,7 @@ dodgr_to_igraph <- function (graph, weight_column = "d")
#' identical (graph2, graph) # FALSE
igraph_to_dodgr <- function (graph)
{
requireNamespace ("igraph")
ei <- igraph::edge_attr (graph)
vi <- igraph::vertex_attr (graph)
index <- grep ("^lon|^lat|lon$|lat$|^x|^y|x$|y$", names (ei))
Expand Down Expand Up @@ -220,9 +222,8 @@ convert_col <- function (x, n = 3)
#' grapht <- dodgr_to_tidygraph (graph)
dodgr_to_tidygraph <- function (graph)
{
if (!requireNamespace ("tidygraph"))
stop (paste0 ("dodgr_to_tidygraph requires the ", # nocov
"tidygraph package to be installed.")) # nocov
requireNamespace ("igraph")
requireNamespace ("tidygraph")

dodgr_to_igraph (graph) %>%
tidygraph::as_tbl_graph ()
Expand Down
28 changes: 14 additions & 14 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"codeRepository": "https://github.com/ATFutures/dodgr",
"issueTracker": "https://github.com/ATFutures/dodgr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.2.5.9",
"version": "0.2.5.10",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -107,6 +107,18 @@
},
"sameAs": "https://CRAN.R-project.org/package=ggplot2"
},
{
"@type": "SoftwareApplication",
"identifier": "igraph",
"name": "igraph",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=igraph"
},
{
"@type": "SoftwareApplication",
"identifier": "igraphdata",
Expand Down Expand Up @@ -283,18 +295,6 @@
},
"sameAs": "https://CRAN.R-project.org/package=digest"
},
{
"@type": "SoftwareApplication",
"identifier": "igraph",
"name": "igraph",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=igraph"
},
{
"@type": "SoftwareApplication",
"identifier": "magrittr",
Expand Down Expand Up @@ -392,5 +392,5 @@
}
],
"relatedLink": "https://CRAN.R-project.org/package=dodgr",
"fileSize": "642.845KB"
"fileSize": "376.773KB"
}
5 changes: 5 additions & 0 deletions man/dodgr_centrality.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9db1016

Please sign in to comment.