MCPcopy
hub / github.com/dmlc/dgl / sample_subgraphs

Method sample_subgraphs

examples/graphbolt/sparse/graphsage.py:117–135  ·  view source on GitHub ↗
(self, seeds, seeds_timestamp=None)

Source from the content-addressed store, hash-verified

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############################################################################

Callers

nothing calls this directly

Calls 4

coalesceMethod · 0.80
compactMethod · 0.80
longMethod · 0.45
sampleMethod · 0.45

Tested by

no test coverage detected