dmlc--dgl
bf264d00fe
* adding LABOR sampling * add ladies and pladies samplers * fix compile error after rebase * add reference for ladies sampler * Improve ladies implementation. * weighted labor sampling initial implementation draft fix indentation and small bug in ladies script * importance_sampling currently doesn't work with weights * fix weighted importance sampling * move labor example into its own folder * lint fixes * Improve documentation * remove examples from the main PR * fix linting by not using c++17 features * fix documentation of labor_sampler.py * update documentation for labor.py * reformat the labor.py file with black * fix linting errors * replace exception use with if * fix typo in error comment * fixing win64 build for ci * fixing weighted implementation, works now. * fix bug in the weighted case and importance_sampling==0 * address part of the reviews * remove unused code paths from cuda * remove unused code path from cpu side * remove extra features of labor making use of random seed. * fix exclude_edges bug * remove pcg and seed logic from cpu implementation, seed logic should still work for cuda. * minor style change * refactor CPU implementation, take out the importance_sampling probability computation into a function. * improve CUDAWorkspaceAllocator * refactor importance_sampling part out to a function * minor optimization * fix linting issue * Revert "remove pcg and seed logic from cpu implementation, seed logic should still work for cuda." This reverts commit c250e07ac6d7e13f57e79e8a2c2f098d777378c2. * Revert "remove extra features of labor making use of random seed." This reverts commit 7f99034353080308f4783f27d9a08bea343fb796. * fix the documentation * disable NIDs * improve the documentation in the code * use the stream argument in pcg32 instead of skipping ahead t times, can discard the use of hashmap now since it is faster this way. * fix linting issue * address another round of reviews * further optimize CPU LABOR sampling implementation * fix linting error * update the comment * reformat * rename and rephrase comment * fix formatting according to new linting specs * fix compile error due to renaming, fix linting. * lint * rename DGLHeteroGraph to DGLGraph to match master * replace other occurrences of DGLHeteroGraph to DGLGraph Co-authored-by: Muhammed Fatih BALIN <m.f.balin@gmail.com> Co-authored-by: Kaan Sancak <kaansnck@gmail.com> Co-authored-by: Quan Gan <coin2028@hotmail.com>
60 行
1.8 KiB
C++
60 行
1.8 KiB
C++
/**
|
|
* Copyright (c) 2018 by Contributors
|
|
* @file dgl/sampler.h
|
|
* @brief DGL sampler header.
|
|
*/
|
|
#ifndef DGL_SAMPLER_H_
|
|
#define DGL_SAMPLER_H_
|
|
|
|
#include <cstdlib>
|
|
#include <ctime>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "graph_interface.h"
|
|
#include "nodeflow.h"
|
|
|
|
namespace dgl {
|
|
|
|
class ImmutableGraph;
|
|
|
|
class SamplerOp {
|
|
public:
|
|
/**
|
|
* @brief Sample a graph from the seed vertices with neighbor sampling.
|
|
* The neighbors are sampled with a uniform distribution.
|
|
*
|
|
* @param graph A graph for sampling.
|
|
* @param seeds the nodes where we should start to sample.
|
|
* @param edge_type the type of edges we should sample neighbors.
|
|
* @param num_hops the number of hops to sample neighbors.
|
|
* @param expand_factor the max number of neighbors to sample.
|
|
* @param add_self_loop whether to add self loop to the sampled subgraph
|
|
* @param probability the transition probability (float/double).
|
|
* @return a NodeFlow graph.
|
|
*/
|
|
template <typename ValueType>
|
|
static NodeFlow NeighborSample(
|
|
const ImmutableGraph *graph, const std::vector<dgl_id_t> &seeds,
|
|
const std::string &edge_type, int num_hops, int expand_factor,
|
|
const bool add_self_loop, const ValueType *probability);
|
|
|
|
/**
|
|
* @brief Sample a graph from the seed vertices with layer sampling.
|
|
* The layers are sampled with a uniform distribution.
|
|
*
|
|
* @param graph A graph for sampling.
|
|
* @param seeds the nodes where we should start to sample.
|
|
* @param edge_type the type of edges we should sample neighbors.
|
|
* @param layer_sizes The size of layers.
|
|
* @return a NodeFlow graph.
|
|
*/
|
|
static NodeFlow LayerUniformSample(
|
|
const ImmutableGraph *graph, const std::vector<dgl_id_t> &seeds,
|
|
const std::string &neigh_type, IdArray layer_sizes);
|
|
};
|
|
|
|
} // namespace dgl
|
|
|
|
#endif // DGL_SAMPLER_H_
|