Skip to content

Commit

Permalink
Merge pull request #5 from kevinykuo/feature/cran-resubmit
Browse files Browse the repository at this point in the history
Address CRAN reviewer comments
  • Loading branch information
kevinykuo authored Apr 6, 2018
2 parents c586115 + 8717aca commit ce75b23
Show file tree
Hide file tree
Showing 28 changed files with 221 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
demo.R
derby.log
log4j.spark.*
internal
14 changes: 10 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
Package: graphframes
Type: Package
Title: R Interface for GraphFrames
Title: Interface for 'GraphFrames'
Version: 0.1.0
Authors@R: person("Kevin", "Kuo", email = "[email protected]", role = c("aut", "cre"))
Authors@R: person("Kevin", "Kuo", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7803-7901"))
Maintainer: Kevin Kuo <[email protected]>
Description: A sparklyr <https://spark.rstudio.com/> extension that provides an R
interface for GraphFrames <https://graphframes.github.io/>.
Description: A 'sparklyr' <https://spark.rstudio.com/> extension that provides an R
interface for 'GraphFrames' <https://graphframes.github.io/>. 'GraphFrames' is a package
for 'Apache Spark' that provides a DataFrame-based API for working with graphs. Functionality
includes motif finding and common graph algorithms, such as PageRank and Breadth-first
search.
URL: https://github.com/rstudio/graphframes
BugReports: https://github.com/rstudio/graphframes/issues
License: Apache License 2.0 | file LICENSE
Encoding: UTF-8
LazyData: true
Expand Down
5 changes: 5 additions & 0 deletions R/gf_bfs.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#' @param edge_filter Spark SQL expression specifying edges which may be used in the search.
#' @template roxlate-gf-dots
#'
#' @examples
#' \dontrun{
#' g <- gf_friends(sc)
#' gf_bfs(g, from_expr = "name = 'Esther'", to_expr = "age < 32")
#' }
#' @export
gf_bfs <- function(x,
from_expr,
Expand Down
7 changes: 7 additions & 0 deletions R/gf_connected_components.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
#' @param algorithm One of 'graphframes' or 'graphx'.
#' @param checkpoint_interval Checkpoint interval in terms of number of iterations.
#' @template roxlate-gf-dots
#' @examples
#' \dontrun{
#' # checkpoint directory is required for gf_connected_components()
#' spark_set_checkpoint_dir(sc, tempdir())
#' g <- gf_friends(sc)
#' gf_connected_components(g)
#' }
#' @export
gf_connected_components <- function(x,
broadcast_threshold = 1000000L,
Expand Down
25 changes: 25 additions & 0 deletions R/gf_examples.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#' Graph of friends in a social network.
#'
#' @examples
#' \dontrun{
#' library(sparklyr)
#' sc <- spark_connect(master = "local")
#' gf_friends(sc)
#' }
#' @template roxlate-gf-sc
#' @export
gf_friends <- function(sc) {
Expand All @@ -14,6 +20,10 @@ gf_friends <- function(sc) {
#' The vertex IDs are 0, 1, ..., n-1, and the edges are (0, 1), (1, 2), ...., (n-2, n-1).
#' @template roxlate-gf-sc
#' @param n Size of the graph to return.
#' @examples
#' \dontrun{
#' gf_chain(sc, 5)
#' }
#' @export
gf_chain <- function(sc, n) {
n <- ensure_scalar_integer(n)
Expand Down Expand Up @@ -41,6 +51,11 @@ gf_chain <- function(sc, n) {
#' "dst", and "b". Edges are directed, but they should be treated as undirected in
#' any algorithms run on this model. Vertex IDs are of the form "i,j". E.g., vertex
#' "1,3" is in the second row and fourth column of the grid.
#'
#' @examples
#' \dontrun{
#' gf_grid_ising_model(sc, 5)
#' }
#' @export
gf_grid_ising_model <- function(sc, n, v_std = 1, e_std = 1) {
sql_context <- invoke_new(sc, "org.apache.spark.sql.SQLContext", spark_context(sc))
Expand All @@ -59,6 +74,11 @@ gf_grid_ising_model <- function(sc, n, v_std = 1, e_std = 1) {
#' indexed 0 (the root) and the n other leaf vertices 1, 2, ..., n.
#' @template roxlate-gf-sc
#' @param n The number of leaves.
#'
#' @examples
#' \dontrun{
#' gf_star(sc, 5)
#' }
#' @export
gf_star <- function(sc, n) {
n <- ensure_scalar_integer(n)
Expand All @@ -74,6 +94,11 @@ gf_star <- function(sc, n) {
#' connected by a single edge (0->n).
#' @template roxlate-gf-sc
#' @param blob_size The size of each blob.
#'
#' @examples
#' \dontrun{
#' gf_two_blobs(sc, 3)
#' }
#' @export
gf_two_blobs <- function(sc, blob_size) {
blob_size <- ensure_scalar_integer(blob_size)
Expand Down
30 changes: 30 additions & 0 deletions R/gf_interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ new_graphframe <- function(jobj) {
#'
#' @param vertices A \code{tbl_spark} representing vertices.
#' @param edges A \code{tbl_psark} representing edges.
#'
#' @examples
#' \dontrun{
#' library(sparklyr)
#' sc <- spark_connect(master = "local", version = "2.1.0")
#' v_tbl <- sdf_copy_to(
#' sc, data.frame(id = 1:3, name = LETTERS[1:3])
#' )
#' e_tbl <- sdf_copy_to(
#' sc, data.frame(src = c(1, 2, 2), dst = c(2, 1, 3),
#' action = c("love", "hate", "follow"))
#' )
#' gf_graphframe(v_tbl, e_tbl)
#' gf_graphframe(edges = e_tbl)
#' }
#' @export
gf_graphframe <- function(vertices = NULL, edges) {
sc <- edges %>%
Expand Down Expand Up @@ -170,10 +185,25 @@ gf_degrees <- function(x) {
}

#' Motif finding: Searching the graph for structural patterns
#'
#' Motif finding uses a simple Domain-Specific Language (DSL) for
#' expressing structural queries. For example,
#' gf_find(g, "(a)-[e]->(b); (b)-[e2]->(a)") will search for
#' pairs of vertices a,b connected by edges in both directions.
#' It will return a DataFrame of all such structures in the graph,
#' with columns for each of the named elements (vertices or edges)
#' in the motif. In this case, the returned columns will be in
#' order of the pattern: "a, e, b, e2."
#'
#' @template roxlate-gf-x
#'
#' @param pattern pattern specifying a motif to search for
#'
#' @examples
#' \dontrun{
#' gf_friends(sc) %>%
#' gf_find("(a)-[e]->(b); (b)-[e2]->(a)")
#' }
#' @export
gf_find <- function(x, pattern) {
ensure_scalar_character(pattern)
Expand Down
6 changes: 6 additions & 0 deletions R/gf_lpa.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#' @template roxlate-gf-x
#' @param max_iter Maximum number of iterations.
#' @template roxlate-gf-dots
#'
#' @examples
#' \dontrun{
#' g <- gf_friends(sc)
#' gf_lpa(g, max_iter = 5)
#' }
#' @export
gf_lpa <- function(x, max_iter, ...) {
max_iter <- ensure_scalar_integer(max_iter)
Expand Down
6 changes: 6 additions & 0 deletions R/gf_pagerank.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#' @param max_iter Maximum number of iterations.
#' @param source_id (Optional) Source vertex for a personalized pagerank.
#' @template roxlate-gf-dots
#'
#' @examples
#' \dontrun{
#' g <- gf_friends(sc)
#' gf_pagerank(g, reset_probability = 0.15, tol = 0.01)
#' }
#' @export
gf_pagerank <- function(x, tol = NULL, reset_probability = 0.15, max_iter = NULL,
source_id = NULL, ...) {
Expand Down
6 changes: 6 additions & 0 deletions R/gf_scc.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#' @template roxlate-gf-x
#' @param max_iter Maximum number of iterations.
#' @template roxlate-gf-dots
#'
#' @examples
#' \dontrun{
#' g <- gf_friends(sc)
#' gf_scc(g, max_iter = 10)
#' }
#' @export
gf_scc <- function(x, max_iter, ...) {
max_iter <- ensure_scalar_integer(max_iter)
Expand Down
6 changes: 6 additions & 0 deletions R/gf_shortest_paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#' @template roxlate-gf-x
#' @param landmarks IDs of landmark vertices.
#' @template roxlate-gf-dots
#'
#' @examples
#' \dontrun{
#' g <- gf_friends(sc)
#' gf_shortest_paths(g, landmarks = c("a", "d"))
#' }
#' @export
gf_shortest_paths <- function(x, landmarks, ...) {
landmarks <- lapply(landmarks, ensure_scalar_character)
Expand Down
6 changes: 6 additions & 0 deletions R/gf_triangle_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#'
#' @template roxlate-gf-x
#' @template roxlate-gf-dots
#'
#' @examples
#' \dontrun{
#' g <- gf_friends(sc)
#' gf_triangle_count(g)
#' }
#' @export
gf_triangle_count <- function(x, ...) {
gf <- spark_graphframe(x)
Expand Down
4 changes: 3 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ knitr::opts_chunk$set(fig.path = "tools/readme/", dev = "png")
For those already using `sparklyr` simply run:

```{r eval=FALSE}
devtools::install_github("rstudio/graphframes")
install.packages("graphframes")
# or, for the development version,
# devtools::install_github("rstudio/graphframes")
```

Otherwise, install first `sparklyr` from CRAN using:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Installation
For those already using `sparklyr` simply run:

``` r
devtools::install_github("rstudio/graphframes")
install.packages("graphframes")
# or, for the development version,
# devtools::install_github("rstudio/graphframes")
```

Otherwise, install first `sparklyr` from CRAN using:
Expand Down Expand Up @@ -79,7 +81,7 @@ For instance, one can calcualte the degrees of vertices using `gf_degrees` as fo
gf_graphframe(vertices_tbl, edges_tbl) %>% gf_degrees()
```

## # Source: table<sparklyr_tmp_16dc314afea5c> [?? x 2]
## # Source: table<sparklyr_tmp_e0776727325e> [?? x 2]
## # Database: spark_connection
## id degree
## <dbl> <int>
Expand Down
11 changes: 6 additions & 5 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Resubmission

This is a resubmission. Changes:

- Enclose 'GraphFrames' in single quotes in the title.

## Test environments
* local OS X install, R 3.4.4
* ubuntu 14.04 (on travis-ci), R 3.4.4
Expand All @@ -9,8 +15,3 @@ There were no ERRORs or WARNINGs.
There was 1 NOTE:

* New submission
* Possibly mis-spelled words in DESCRIPTION:
GraphFrames (3:24, 8:17)
sparklyr (7:16)

This is a new submission. Spelling is correct.
6 changes: 6 additions & 0 deletions man/gf_bfs.Rd

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

5 changes: 5 additions & 0 deletions man/gf_chain.Rd

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

8 changes: 8 additions & 0 deletions man/gf_connected_components.Rd

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

15 changes: 14 additions & 1 deletion man/gf_find.Rd

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

7 changes: 7 additions & 0 deletions man/gf_friends.Rd

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

15 changes: 15 additions & 0 deletions man/gf_graphframe.Rd

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

5 changes: 5 additions & 0 deletions man/gf_grid_ising_model.Rd

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

6 changes: 6 additions & 0 deletions man/gf_lpa.Rd

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

6 changes: 6 additions & 0 deletions man/gf_pagerank.Rd

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

6 changes: 6 additions & 0 deletions man/gf_scc.Rd

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

Loading

0 comments on commit ce75b23

Please sign in to comment.