Skip to content

Commit ce75b23

Browse files
authored
Merge pull request #5 from kevinykuo/feature/cran-resubmit
Address CRAN reviewer comments
2 parents c586115 + 8717aca commit ce75b23

28 files changed

+221
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
demo.R
66
derby.log
77
log4j.spark.*
8+
internal

DESCRIPTION

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
Package: graphframes
22
Type: Package
3-
Title: R Interface for GraphFrames
3+
Title: Interface for 'GraphFrames'
44
Version: 0.1.0
5-
Authors@R: person("Kevin", "Kuo", email = "kevin.kuo@rstudio.com", role = c("aut", "cre"))
5+
Authors@R: person("Kevin", "Kuo", email = "kevin.kuo@rstudio.com",
6+
role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7803-7901"))
67
Maintainer: Kevin Kuo <kevin.kuo@rstudio.com>
7-
Description: A sparklyr <https://spark.rstudio.com/> extension that provides an R
8-
interface for GraphFrames <https://graphframes.github.io/>.
8+
Description: A 'sparklyr' <https://spark.rstudio.com/> extension that provides an R
9+
interface for 'GraphFrames' <https://graphframes.github.io/>. 'GraphFrames' is a package
10+
for 'Apache Spark' that provides a DataFrame-based API for working with graphs. Functionality
11+
includes motif finding and common graph algorithms, such as PageRank and Breadth-first
12+
search.
13+
URL: https://github.com/rstudio/graphframes
14+
BugReports: https://github.com/rstudio/graphframes/issues
915
License: Apache License 2.0 | file LICENSE
1016
Encoding: UTF-8
1117
LazyData: true

R/gf_bfs.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
#' @param edge_filter Spark SQL expression specifying edges which may be used in the search.
99
#' @template roxlate-gf-dots
1010
#'
11+
#' @examples
12+
#' \dontrun{
13+
#' g <- gf_friends(sc)
14+
#' gf_bfs(g, from_expr = "name = 'Esther'", to_expr = "age < 32")
15+
#' }
1116
#' @export
1217
gf_bfs <- function(x,
1318
from_expr,

R/gf_connected_components.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
#' @param algorithm One of 'graphframes' or 'graphx'.
99
#' @param checkpoint_interval Checkpoint interval in terms of number of iterations.
1010
#' @template roxlate-gf-dots
11+
#' @examples
12+
#' \dontrun{
13+
#' # checkpoint directory is required for gf_connected_components()
14+
#' spark_set_checkpoint_dir(sc, tempdir())
15+
#' g <- gf_friends(sc)
16+
#' gf_connected_components(g)
17+
#' }
1118
#' @export
1219
gf_connected_components <- function(x,
1320
broadcast_threshold = 1000000L,

R/gf_examples.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#' Graph of friends in a social network.
22
#'
3+
#' @examples
4+
#' \dontrun{
5+
#' library(sparklyr)
6+
#' sc <- spark_connect(master = "local")
7+
#' gf_friends(sc)
8+
#' }
39
#' @template roxlate-gf-sc
410
#' @export
511
gf_friends <- function(sc) {
@@ -14,6 +20,10 @@ gf_friends <- function(sc) {
1420
#' The vertex IDs are 0, 1, ..., n-1, and the edges are (0, 1), (1, 2), ...., (n-2, n-1).
1521
#' @template roxlate-gf-sc
1622
#' @param n Size of the graph to return.
23+
#' @examples
24+
#' \dontrun{
25+
#' gf_chain(sc, 5)
26+
#' }
1727
#' @export
1828
gf_chain <- function(sc, n) {
1929
n <- ensure_scalar_integer(n)
@@ -41,6 +51,11 @@ gf_chain <- function(sc, n) {
4151
#' "dst", and "b". Edges are directed, but they should be treated as undirected in
4252
#' any algorithms run on this model. Vertex IDs are of the form "i,j". E.g., vertex
4353
#' "1,3" is in the second row and fourth column of the grid.
54+
#'
55+
#' @examples
56+
#' \dontrun{
57+
#' gf_grid_ising_model(sc, 5)
58+
#' }
4459
#' @export
4560
gf_grid_ising_model <- function(sc, n, v_std = 1, e_std = 1) {
4661
sql_context <- invoke_new(sc, "org.apache.spark.sql.SQLContext", spark_context(sc))
@@ -59,6 +74,11 @@ gf_grid_ising_model <- function(sc, n, v_std = 1, e_std = 1) {
5974
#' indexed 0 (the root) and the n other leaf vertices 1, 2, ..., n.
6075
#' @template roxlate-gf-sc
6176
#' @param n The number of leaves.
77+
#'
78+
#' @examples
79+
#' \dontrun{
80+
#' gf_star(sc, 5)
81+
#' }
6282
#' @export
6383
gf_star <- function(sc, n) {
6484
n <- ensure_scalar_integer(n)
@@ -74,6 +94,11 @@ gf_star <- function(sc, n) {
7494
#' connected by a single edge (0->n).
7595
#' @template roxlate-gf-sc
7696
#' @param blob_size The size of each blob.
97+
#'
98+
#' @examples
99+
#' \dontrun{
100+
#' gf_two_blobs(sc, 3)
101+
#' }
77102
#' @export
78103
gf_two_blobs <- function(sc, blob_size) {
79104
blob_size <- ensure_scalar_integer(blob_size)

R/gf_interface.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ new_graphframe <- function(jobj) {
3434
#'
3535
#' @param vertices A \code{tbl_spark} representing vertices.
3636
#' @param edges A \code{tbl_psark} representing edges.
37+
#'
38+
#' @examples
39+
#' \dontrun{
40+
#' library(sparklyr)
41+
#' sc <- spark_connect(master = "local", version = "2.1.0")
42+
#' v_tbl <- sdf_copy_to(
43+
#' sc, data.frame(id = 1:3, name = LETTERS[1:3])
44+
#' )
45+
#' e_tbl <- sdf_copy_to(
46+
#' sc, data.frame(src = c(1, 2, 2), dst = c(2, 1, 3),
47+
#' action = c("love", "hate", "follow"))
48+
#' )
49+
#' gf_graphframe(v_tbl, e_tbl)
50+
#' gf_graphframe(edges = e_tbl)
51+
#' }
3752
#' @export
3853
gf_graphframe <- function(vertices = NULL, edges) {
3954
sc <- edges %>%
@@ -170,10 +185,25 @@ gf_degrees <- function(x) {
170185
}
171186

172187
#' Motif finding: Searching the graph for structural patterns
188+
#'
189+
#' Motif finding uses a simple Domain-Specific Language (DSL) for
190+
#' expressing structural queries. For example,
191+
#' gf_find(g, "(a)-[e]->(b); (b)-[e2]->(a)") will search for
192+
#' pairs of vertices a,b connected by edges in both directions.
193+
#' It will return a DataFrame of all such structures in the graph,
194+
#' with columns for each of the named elements (vertices or edges)
195+
#' in the motif. In this case, the returned columns will be in
196+
#' order of the pattern: "a, e, b, e2."
197+
#'
173198
#' @template roxlate-gf-x
174199
#'
175200
#' @param pattern pattern specifying a motif to search for
176201
#'
202+
#' @examples
203+
#' \dontrun{
204+
#' gf_friends(sc) %>%
205+
#' gf_find("(a)-[e]->(b); (b)-[e2]->(a)")
206+
#' }
177207
#' @export
178208
gf_find <- function(x, pattern) {
179209
ensure_scalar_character(pattern)

R/gf_lpa.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
#' @template roxlate-gf-x
1212
#' @param max_iter Maximum number of iterations.
1313
#' @template roxlate-gf-dots
14+
#'
15+
#' @examples
16+
#' \dontrun{
17+
#' g <- gf_friends(sc)
18+
#' gf_lpa(g, max_iter = 5)
19+
#' }
1420
#' @export
1521
gf_lpa <- function(x, max_iter, ...) {
1622
max_iter <- ensure_scalar_integer(max_iter)

R/gf_pagerank.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
#' @param max_iter Maximum number of iterations.
77
#' @param source_id (Optional) Source vertex for a personalized pagerank.
88
#' @template roxlate-gf-dots
9+
#'
10+
#' @examples
11+
#' \dontrun{
12+
#' g <- gf_friends(sc)
13+
#' gf_pagerank(g, reset_probability = 0.15, tol = 0.01)
14+
#' }
915
#' @export
1016
gf_pagerank <- function(x, tol = NULL, reset_probability = 0.15, max_iter = NULL,
1117
source_id = NULL, ...) {

R/gf_scc.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
#' @template roxlate-gf-x
77
#' @param max_iter Maximum number of iterations.
88
#' @template roxlate-gf-dots
9+
#'
10+
#' @examples
11+
#' \dontrun{
12+
#' g <- gf_friends(sc)
13+
#' gf_scc(g, max_iter = 10)
14+
#' }
915
#' @export
1016
gf_scc <- function(x, max_iter, ...) {
1117
max_iter <- ensure_scalar_integer(max_iter)

R/gf_shortest_paths.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
#' @template roxlate-gf-x
77
#' @param landmarks IDs of landmark vertices.
88
#' @template roxlate-gf-dots
9+
#'
10+
#' @examples
11+
#' \dontrun{
12+
#' g <- gf_friends(sc)
13+
#' gf_shortest_paths(g, landmarks = c("a", "d"))
14+
#' }
915
#' @export
1016
gf_shortest_paths <- function(x, landmarks, ...) {
1117
landmarks <- lapply(landmarks, ensure_scalar_character)

0 commit comments

Comments
 (0)