code: def _ancestors_and_descendants(G, source, *, is_ancestors):
      G = _to_graph(G)
      if source not in G:
          hash(source)  # To raise TypeError if appropriate
          raise nx.NetworkXError(
              f"The node {source} is not in the {G.__class__.__name__.lower()}."
          )
      src_index = source if G.key_to_id is None else G.key_to_id[source]
      distances, predecessors, node_ids = plc.bfs(
          handle=plc.ResourceHandle(),
          graph=G._get_plc_graph(switch_indices=is_ancestors),
          sources=cp.array([src_index], dtype=index_dtype),
          direction_optimizing=False,
          depth_limit=-1,
          compute_predecessors=False,
          do_expensive_check=False,
      )
      mask = (distances != np.iinfo(distances.dtype).max) & (
          distances != 0
      )
      return G._nodearray_to_set(node_ids[mask])
  
file_path: cugraph/python/nx-cugraph/nx_cugraph/algorithms/dag.py
imports: import cupy
  import networkx
  import numpy
  import pylibcugraph
  from nx_cugraph.convert import _to_graph
  from nx_cugraph.utils import index_dtype, networkx_algorithm
label_desc: Use image node_id 1 for calling a global function with example usage: _ancestors_and_descendants(G, source) and returns: G