pgl.sampling¶
Graph Sampling Function¶
-
pgl.sampling.
graphsage_sample
(graph, nodes, samples, ignore_edges=[])[source]¶ Implement of graphsage sample. Reference paper: https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf. :param graph: A pgl graph instance :param nodes: Sample starting from nodes :param samples: A list, number of neighbors in each layer :param ignore_edges: list of edge(src, dst) will be ignored.
- Returns
A list of subgraphs
-
pgl.sampling.
random_walk
(graph, nodes, max_depth)[source]¶ Implement of random walk.
This function get random walks path for given nodes and depth.
- Parameters
nodes – Walk starting from nodes
max_depth – Max walking depth
- Returns
A list of walks.
-
pgl.sampling.
subgraph
(graph, nodes, eid=None, edges=None, with_node_feat=True, with_edge_feat=True)[source]¶ Generate subgraph with nodes and edge ids. This function will generate a
pgl.graph.Subgraph
object and copy all corresponding node and edge features. Nodes and edges will be reindex from 0. Eid and edges can’t both be None. WARNING: ALL NODES IN EID MUST BE INCLUDED BY NODES- Parameters
nodes – Node ids which will be included in the subgraph.
eid (optional) – Edge ids which will be included in the subgraph.
edges (optional) – Edge(src, dst) list which will be included in the subgraph.
with_node_feat – Whether to inherit node features from parent graph.
with_edge_feat – Whether to inherit edge features from parent graph.
- Returns
A
pgl.Graph
object.