| 115 | self.fanouts.insert(0, fanout) |
| 116 | |
| 117 | def sample_subgraphs(self, seeds, seeds_timestamp=None): |
| 118 | sampled_matrices = [] |
| 119 | src = seeds.long() |
| 120 | |
| 121 | ##################################################################### |
| 122 | # (HIGHLIGHT) Using the sparse sample operator to preform random |
| 123 | # sampling on the neighboring nodes of the seeds nodes. The sparse |
| 124 | # compact operator is then employed to compact and relabel the sampled |
| 125 | # matrix, resulting in the sampled matrix and the relabel index. |
| 126 | ##################################################################### |
| 127 | for fanout in self.fanouts: |
| 128 | # Sample neighbors. |
| 129 | sampled_matrix = self.matrix.sample(1, fanout, ids=src).coalesce() |
| 130 | # Compact the sampled matrix. |
| 131 | compacted_mat, row_ids = sampled_matrix.compact(0) |
| 132 | sampled_matrices.insert(0, compacted_mat) |
| 133 | src = row_ids |
| 134 | |
| 135 | return src, sampled_matrices |
| 136 | |
| 137 | |
| 138 | ############################################################################ |