Skip to content

Commit b87b8e3

Browse files
committed
Prep for CRAN release
1 parent c64ebb0 commit b87b8e3

File tree

2 files changed

+43
-41
lines changed

2 files changed

+43
-41
lines changed

README.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ status](https://www.r-pkg.org/badges/version/fastRG)](https://CRAN.R-project.org
1414

1515
`fastRG` quickly samples a broad class of network models known as
1616
generalized random dot product graphs (GRDPGs). In particular, for
17-
matrices $X$, $S$ and $Y$, `fastRG` samples a matrix $A$ with
18-
expectation $X S Y^T$ where the entries are independently Poisson
19-
distributed conditional on $X$ and $Y$. This is primarily useful when
20-
$A$ is the adjacency matrix of a graph. Crucially, the sampling is
21-
$\mathcal O(m)$, where $m$ is the number of the edges in graph, as
22-
opposed to the naive sampling approach, which is $\mathcal O(n^2)$,
23-
where $n$ is the number of nodes in the network. For additional details,
24-
see the [paper](https://arxiv.org/abs/1703.02998) \[1\].
17+
matrices $`X`$, $`S`$ and $`Y`$, `fastRG` samples a matrix $`A`$ with
18+
expectation $`X S Y^T`$ where the entries are independently Poisson
19+
distributed conditional on $`X`$ and $`Y`$. This is primarily useful
20+
when $`A`$ is the adjacency matrix of a graph. Crucially, the sampling
21+
is $`\mathcal O(m)`$, where $`m`$ is the number of the edges in graph,
22+
as opposed to the naive sampling approach, which is $`\mathcal O(n^2)`$,
23+
where $`n`$ is the number of nodes in the network. For additional
24+
details, see the [paper](https://arxiv.org/abs/1703.02998) \[1\].
2525

2626
`fastRG` has two primary use cases:
2727

@@ -52,10 +52,10 @@ devtools::install_github("RoheLab/fastRG")
5252
## Usage
5353

5454
There are two stages to sampling from generalized random dot product
55-
graphs. First, we sample the latent factors $X$ and $Y$. Then we sample
56-
$A$ conditional on those latent factors. `fastRG` mimics this two-stage
57-
sample structure. For example, to sample from a stochastic blockmodel,
58-
we first create the latent factors.
55+
graphs. First, we sample the latent factors $`X`$ and $`Y`$. Then we
56+
sample $`A`$ conditional on those latent factors. `fastRG` mimics this
57+
two-stage sample structure. For example, to sample from a stochastic
58+
blockmodel, we first create the latent factors.
5959

6060
``` r
6161
library(fastRG)
@@ -67,8 +67,8 @@ sbm <- sbm(n = 1000, k = 5, expected_density = 0.01)
6767
#> Generating random mixing matrix `B` with independent Uniform(0, 1) entries. This distribution may change in the future. Explicitly set `B` for reproducible results.
6868
```
6969

70-
You can specify the latent factors and the mixing matrix $B$ yourself,
71-
but there are also defaults to enable fast prototyping. Here $B$ was
70+
You can specify the latent factors and the mixing matrix $`B`$ yourself,
71+
but there are also defaults to enable fast prototyping. Here $`B`$ was
7272
randomly generated with `Uniform[0, 1]` entries and nodes were assigned
7373
randomly to communities with equal probability of falling in all
7474
communities. Printing the result object gives us some additional
@@ -106,20 +106,20 @@ obtain an edgelist in a `tibble` with:
106106

107107
``` r
108108
sample_edgelist(sbm)
109-
#> # A tibble: 4,985 × 2
109+
#> # A tibble: 2,484 × 2
110110
#> from to
111111
#> <int> <int>
112-
#> 1 111 127
113-
#> 2 86 109
114-
#> 3 43 97
115-
#> 4 61 94
116-
#> 5 22 143
117-
#> 6 4 89
118-
#> 7 30 159
119-
#> 8 119 210
120-
#> 9 41 197
121-
#> 10 145 175
122-
#> # ℹ 4,975 more rows
112+
#> 1 4 155
113+
#> 2 46 141
114+
#> 3 42 56
115+
#> 4 42 55
116+
#> 5 72 167
117+
#> 6 32 68
118+
#> 7 67 75
119+
#> 8 10 164
120+
#> 9 30 154
121+
#> 10 74 182
122+
#> # ℹ 2,474 more rows
123123
```
124124

125125
but we can just as easily obtain the graph as a sparse matrix
@@ -145,17 +145,17 @@ or an igraph object
145145

146146
``` r
147147
sample_igraph(sbm)
148-
#> IGRAPH be5b840 UN-- 1000 5033 --
148+
#> IGRAPH 2e1d765 UN-- 1000 2447 --
149149
#> + attr: name (v/c)
150-
#> + edges from be5b840 (vertex names):
151-
#> [1] 63 --76 135--215 59 --182 21 --134 180--218 53 --189 138--139 21 --78
152-
#> [9] 49 --70 76 --127 6 --139 64 --214 31 --132 56 --93 75 --144 9 --185
153-
#> [17] 33 --150 115--165 163--213 6 --53 47 --179 25 --26 7 --51 10 --55
154-
#> [25] 120--183 43 --152 25 --34 84 --216 114--191 34 --127 152--164 178--189
155-
#> [33] 106--181 28 --38 41 --89 34 --139 6 --213 24 --153 32 --173 47 --111
156-
#> [41] 157--205 108--133 98 --116 26 --117 18 --194 18 --32 74 --209 18 --128
157-
#> [49] 13 --127 12 --26 1 --133 52 --72 128--213 13 --173 61 --214 33 --142
158-
#> [57] 22 --111 163--191 191--205 5 --108 9 --72 6 --217 113--122 90 --154
150+
#> + edges from 2e1d765 (vertex names):
151+
#> [1] 125--139 30 --36 36 --57 76 --108 46 --128 44 --179 49 --199 9 --69
152+
#> [9] 17 --154 100--154 58 --138 22 --182 27 --92 109--143 44 --195 96 --153
153+
#> [17] 7 --68 121--159 17 --42 132--171 53 --145 15 --33 68 --78 58 --99
154+
#> [25] 158--169 34 --159 128--194 23 --74 6 --126 33 --139 33 --128 80 --107
155+
#> [33] 8 --55 45 --156 120--133 8 --88 120--138 15 --26 123--173 26 --68
156+
#> [41] 145--148 77 --123 1 --110 20 --41 90 --184 72 --191 37 --90 36 --192
157+
#> [49] 101--119 116--131 159--188 37 --58 50 --170 6 --40 132--154 157--194
158+
#> [57] 130--136 14 --143 89 --195 143--173 72 --81 30 --184 159--176 34 --126
159159
#> + ... omitted several edges
160160
```
161161

@@ -178,7 +178,7 @@ straightforward:
178178
``` r
179179
s <- eigs_sym(sbm)
180180
s$values
181-
#> [1] 5.0999835 1.8365365 0.6679806 -0.5241303 -0.8109449
181+
#> [1] 5.0838486 1.8176036 0.6987030 -0.5157282 -0.8208442
182182
```
183183

184184
Note that eigendecompositions and SVDS (for directed graphs) use
@@ -214,8 +214,8 @@ In the second stage of graph sampling, the options are:
214214
## Related work
215215

216216
[`igraph`](https://igraph.org/r/) allows users to sample SBMs (in
217-
$\mathcal O(m + n + k^2)$ time) and random dot product graphs (in
218-
$\mathcal O(n^2 k)$ time).
217+
$`\mathcal O(m + n + k^2)`$ time) and random dot product graphs (in
218+
$`\mathcal O(n^2 k)`$ time).
219219

220220
You can find the original research code associated with `fastRG`
221221
[here](https://github.com/raningtky/sampleRDPG). There is also a Python

cran-comments.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
This is a minor maintenance release, correcting NOTEs about documentation, as
2-
requested by CRAN.
1+
This releases includes some minor but breaking changes to SBM sampling API
2+
as well as a major bug fix related to oversampling edges in undirected graphs.
3+
Additionally, I wrote a vignette demonstrating how the package can be used
4+
in a simulation study.

0 commit comments

Comments
 (0)