Create a Base NegativeSampler instance. Args: graph (`Graph` object): The graph which sample from. object_type (string): Sample negative nodes of the source node with specified edge_type or node_type. expand_factor: An integer, how many negative ids will be sampled
(self,
graph,
object_type,
expand_factor,
strategy="random")
| 27 | """ |
| 28 | |
| 29 | def __init__(self, |
| 30 | graph, |
| 31 | object_type, |
| 32 | expand_factor, |
| 33 | strategy="random"): |
| 34 | """ Create a Base NegativeSampler instance. |
| 35 | |
| 36 | Args: |
| 37 | graph (`Graph` object): The graph which sample from. |
| 38 | object_type (string): Sample negative nodes of the source node with |
| 39 | specified edge_type or node_type. |
| 40 | expand_factor: An integer, how many negative ids will be sampled |
| 41 | for each given id. |
| 42 | strategy (string): "random", "in_degree", "node_weight" are supported. |
| 43 | """ |
| 44 | self._graph = graph |
| 45 | self._object_type = object_type |
| 46 | self._expand_factor = expand_factor |
| 47 | self._strategy = strategy |
| 48 | self._client = self._graph.get_client() |
| 49 | |
| 50 | if object_type in self._graph.get_node_decoders(): |
| 51 | self._dst_type = object_type |
| 52 | elif object_type in self._graph.get_edge_decoders(): |
| 53 | topology = self._graph.get_topology() |
| 54 | self._dst_type = topology.get_dst_type(object_type) |
| 55 | else: |
| 56 | raise ValueError("node or edge type {} is not in the graph" |
| 57 | .format(object_type)) |
| 58 | |
| 59 | self._check() |
| 60 | |
| 61 | def _check(self): |
| 62 | pass |
no test coverage detected