MCPcopy Create free account
hub / github.com/alibaba/graph-learn / node_sampler

Method node_sampler

graphlearn/python/graph.py:734–775  ·  view source on GitHub ↗

Sampler for sample one type of nodes. Args: t (string): Sample nodes of the given type `t`. `t` can be node type which indicates that sampling node dat, otherwise, `t` can be edge type which indicate that sampling source node or dst node of edge data. batch_

(self,
                   t,
                   batch_size=64,
                   strategy="by_order",
                   node_from=pywrap.NodeFrom.NODE,
                   mask=utils.Mask.NONE)

Source from the content-addressed store, hash-verified

732 return True
733
734 def node_sampler(self,
735 t,
736 batch_size=64,
737 strategy="by_order",
738 node_from=pywrap.NodeFrom.NODE,
739 mask=utils.Mask.NONE):
740 """ Sampler for sample one type of nodes.
741
742 Args:
743 t (string): Sample nodes of the given type `t`. `t` can be node type
744 which indicates that sampling node dat, otherwise, `t` can be
745 edge type which indicate that sampling source node or dst node of
746 edge data.
747 batch_size (int, Optional): How many nodes will be returned for get().
748 strategy (string, Optional): Indicates how to sample edges,
749 "by_order", "random" and "shuffle" are supported.
750 "by_order": Get node by order. Raise `graphlearn.OutOfRangeError` when
751 all the nodes are visited. Each node will be visited and only be
752 visited once.
753 "random": Randomly get nodes. No visting state will be hold, so out of
754 range will not happened.
755 "shuffle": Get nodes with shuffle. Raise `graphlearn.OutOfRangeError`
756 when all the nodes are visited. Each node will be visited and only
757 be visited once.
758 node_from (graphlearn.NODE | graphlearn.EDGE_SRC | graphlearn.EDGE_DST):
759 `graphlearn.NODE`: get node from node data, and `t` must be a node
760 type.
761 `graphlearn.EDGE_SRC`: get node from source node of edge data, and `t`
762 must be an edge type.
763 `graphlearn.EDGE_DST`: get node from destination node of edge data, and
764 `t` must be an edge type.
765
766 Return:
767 A `NodeSampler` object.
768 """
769 sampler = utils.strategy2op(strategy, "NodeSampler")
770 return getattr(samplers, sampler)(self,
771 t,
772 batch_size=batch_size,
773 strategy=strategy,
774 node_from=node_from,
775 mask=mask)
776
777 def edge_sampler(self,
778 edge_type,

Callers 4

mainFunction · 0.95
test_node_iterateMethod · 0.80
__init__Method · 0.80

Calls

no outgoing calls

Tested by 3

mainFunction · 0.76
test_node_iterateMethod · 0.64