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

Method __init__

graphlearn/python/sampler/edge_sampler.py:28–63  ·  view source on GitHub ↗

Create a Base EdgeSampler instance. Args: graph (`Graph` object): The graph which sample from. edge_type (string): Sample edges of the specified edge_type. batch_size (int): How many edges will be returned for `get()`. strategy (string, Optional): Sampling strategy. "by_

(self,
               graph,
               edge_type,
               batch_size,
               strategy="by_order",
               mask=utils.Mask.NONE)

Source from the content-addressed store, hash-verified

26 """
27
28 def __init__(self,
29 graph,
30 edge_type,
31 batch_size,
32 strategy="by_order",
33 mask=utils.Mask.NONE):
34 """ Create a Base EdgeSampler instance.
35 Args:
36 graph (`Graph` object): The graph which sample from.
37 edge_type (string): Sample edges of the specified edge_type.
38 batch_size (int): How many edges will be returned for `get()`.
39 strategy (string, Optional): Sampling strategy. "by_order", "random"
40 and "shuffle" are supported.
41 "by_order": get edges by order of how the specified edge is stored,
42 if the specified type of edges are totally visited,
43 `graphlearn.OutOfRangeError` will be raised. Several
44 `EdgeSampler`s with same type will hold a single state.
45 "random": randomly visit edges, no state will be kept.
46 "shuffle": visit the edges with shuffling, if the specified type of
47 edges are totally visited, `graphlearn.OutOfRangeError` will be
48 raised. Several `EdgeSampler`s with same type will hold a single
49 state.
50 """
51 self._graph = graph
52 self._edge_type = edge_type
53 self._batch_size = batch_size
54 self._strategy = strategy
55 self._client = self._graph.get_client()
56 self._mask = mask
57
58 topology = self._graph.get_topology()
59 self._node_decoders = self._graph.get_node_decoders()
60 self._edge_decoders = self._graph.get_edge_decoders()
61
62 self._src_type, self._dst_type = \
63 topology.get_src_type(edge_type), topology.get_dst_type(edge_type)
64
65 def get(self):
66 """ Get batched sampled `Edges`.

Callers

nothing calls this directly

Calls 6

get_clientMethod · 0.80
get_topologyMethod · 0.80
get_node_decodersMethod · 0.80
get_edge_decodersMethod · 0.80
get_src_typeMethod · 0.80
get_dst_typeMethod · 0.80

Tested by

no test coverage detected