class_docstr: Graph modality
  
  Parameters
  ----------
  data: List[str], required
      A list encoding an adjacency matrix, of a user or an item graph, in the sparse triplet format,         e.g., data=[('user1', 'user4', 1.0)].
class_docstr_tok: ["Graph","modality","Parameters","--","--","--","--","--","data",":","List","[","str","]",",","required","A","list","encoding","an","adjacency","matrix",",","of","a","user","or","an","item","graph",",","in","the","sparse","triplet","format",",","e.g.",",","data=","[","(","'user1","'",",","'user4","'",",","1.0",")","]","."]
docstr: Covert a 2d array into sparse triplet format.
  
  Parameters
  ----------
  mat: 2d array, required
      A Numpy 2d array of integers.
  ids: list, optional, default: None
      A list of ids (or labels) of the objects to be used in the output triplet matrix.
  
  Returns
  -------
  A set corresponding to the sparse triplet representation of mat.
docstr_tok: ["Covert","a","2d","array","into","sparse","triplet","format",".","Parameters","--","--","--","--","--","mat",":","2d","array",",","required","A","Numpy","2d","array","of","integers",".","ids",":","list",",","optional",",","default",":","None","A","list","of","ids","(","or","labels",")","of","the","objects","to","be","used","in","the","output","triplet","matrix",".","Returns","--","--","--","-","A","set","corresponding","to","the","sparse","triplet","representation","of","mat","."]
code: def _to_triplet(mat, ids=None):
      """Covert a 2d array into sparse triplet format.
  
      Parameters
      ----------
      mat: 2d array, required
          A Numpy 2d array of integers.
      ids: list, optional, default: None
          A list of ids (or labels) of the objects to be used in the output triplet matrix.
  
      Returns
      -------
      A set corresponding to the sparse triplet representation of mat.
      """
      tuples = set()
      n = mat.shape[0]
      k = mat.shape[1]
  
      if ids is None:
          ids = range(n)
      for n_ in range(n):
          for k_ in range(k):
              j = int(mat[n_, k_])
              tuples.add((ids[n_], ids[j], 1.0))
  
      return tuples
  
file_path: cornac/cornac/data/graph.py
imports: import scipy.sparse
  import numpy
  from tqdm.auto import trange
  from .None import FeatureModality
label_desc: Use image node_id 8 for calling the GraphModality obj's underlying member method code with example usage: obj._to_triplet(mat, ids) and returns: tuples