docstr: For seq [1, 2, 3, 4] and node NO.2,
  the window_size=1 will generate:
      (1, 2) and (2, 3)
docstr_tok: ["For","seq","[","1",",","2",",","3",",","4","]","and","node","NO.2",",","the","window_size=1","will","generate",":","(","1",",","2",")","and","(","2",",","3",")"]
code: def generate_pos_pairs(self, nodes):
      """
      For seq [1, 2, 3, 4] and node NO.2,
      the window_size=1 will generate:
          (1, 2) and (2, 3)
      """
      # random walk
      traces, types = dgl.sampling.random_walk(
          g=self.graph,
          nodes=nodes,
          length=self.walk_length,
          prob="weight",
      )
      traces = traces.tolist()
      self.filter_padding(traces)
  
      # skip-gram
      pairs = []
      for trace in traces:
          for i in range(len(trace)):
              center = trace[i]
              left = max(0, i - self.window_size)
              right = min(len(trace), i + self.window_size + 1)
              pairs.extend([[center, x, 1] for x in trace[left:i]])
              pairs.extend(
                  [[center, x, 1] for x in trace[i + 1 : right]]
              )
  
      return pairs
  
file_path: dgl/examples/pytorch/eges/sampler.py
imports: import dgl
  import numpy
  import torch
label_desc: Use image node_id 4 for calling the Sampler obj's underlying member method code with example usage: obj.generate_pos_pairs(nodes) and returns: pairs