class_docstr: Implemention of Alias-Method
  
  This is an implementation of Alias-Method for sampling efficiently from 
  a discrete probability distribution.
  
  Reference: https://en.wikipedia.org/wiki/Alias_method
  
  Args:
      prob: The discrete probability distribution.
code: def __init__(self, prob):
      self.n = len(prob)
      self.U = np.array(prob) * self.n
      self.K = [i for i in range(len(prob))]
      overfull, underfull = [], []
      for i, U_i in enumerate(self.U):
          if U_i > 1:
              overfull.append(i)
          elif U_i < 1:
              underfull.append(i)
      while len(overfull) and len(underfull):
          i, j = overfull.pop(), underfull.pop()
          self.K[j] = i
          self.U[i] = self.U[i] - (1 - self.U[j])
          if self.U[i] > 1:
              overfull.append(i)
          elif self.U[i] < 1:
              underfull.append(i)
  
file_path: PGL/legacy/examples/line/data_loader.py
imports: import os
  import io
  import sys
  import numpy
  from pgl import graph
  from pgl.utils.logger import log
label_desc: Use image node_id 1 to create a new AliasSampling object  with example: obj = AliasSampling(prob)