parameters: (self, source, neighbors=None)
return_statement: return EgoGraph(data_dict[source],
                      [data_dict[nbr] for nbr in nbrs],
                      [(self._dag.get_node(v).type, _get_feat_spec(v)) for v in [source] + nbrs],
                      n_neighbors)
docstring: Origanizes the data dict as EgoGraphs and then check and return
      the specified `EgoGraph`.
      Args:
        source(str): alias of centric vertices.
        neighbors(list of str): alias of neighbors at each hop.
          Default `None`: automatically generating the positive neighbors for
          centric vertices. It requires that each hop only has one postive
          downstream in GSL.
          Given list of string: the alias of each hop in GSL. The list must
          follow the order of traverse in GSL, and each one should be the postive
          or negative downstream for the front.
docstring_summary: Origanizes the data dict as EgoGraphs and then check and return
      the specified `EgoGraph`.
      Args:
        source(str): alias of centric vertices.
        neighbors(list of str): alias of neighbors at each hop.
          Default `None`: automatically generating the positive neighbors for
          centric vertices. It requires that each hop only has one postive
          downstream in GSL.
          Given list of string: the alias of each hop in GSL. The list must
          follow the order of traverse in GSL, and each one should be the postive
          or negative downstream for the front.
docstring_tokens: Origanizes the data dict as EgoGraphs and then check and return the specified EgoGraph . Args : source ( str ) : alias of centric vertices . neighbors ( list of str ) : alias of neighbors at each hop . Default None : automatically generating the positive neighbors for centric vertices . It requires that each hop only has one postive downstream in GSL . Given list of string : the alias of each hop in GSL . The list must follow the order of traverse in GSL and each one should be the postive or negative downstream for the front .
function: def get_egograph(self, source, neighbors=None):
      """ Origanizes the data dict as EgoGraphs and then check and return
      the specified `EgoGraph`.
      Args:
        source(str): alias of centric vertices.
        neighbors(list of str): alias of neighbors at each hop.
          Default `None`: automatically generating the positive neighbors for
          centric vertices. It requires that each hop only has one postive
          downstream in GSL.
          Given list of string: the alias of each hop in GSL. The list must
          follow the order of traverse in GSL, and each one should be the postive
          or negative downstream for the front.
      """
      data_dict = self.get_data_dict()
      def _get_feat_spec(alias):
        node = self._dag.get_node(alias)
        decoder = node.decoder
        return decoder.feature_spec
  
      source_node = self._dag.get_node(source)
      nbrs = []
      hops = []
      if neighbors:
        # Use specified neighbors to construct EgoGraph.
        if not isinstance(neighbors, list):
          raise ValueError("`neighbors` should be a list of alias")
        pre = source_node
        for nbr in neighbors:
          nbr_node = self._dag.get_node(nbr)
          if not nbr_node in pre.pos_downstreams + pre.neg_downstreams:
            raise ValueError("{} is not the downstream of {}.".format(
              nbr_node.get_alias(), pre.get_alias()))
          nbrs.append(nbr_node.get_alias())
          hops.append(nbr_node.shape[-1])
          pre = nbr_node
      else:
        # Use default receptive neighbors to construct EgoGraph.
        pre = source_node
        recepts = source_node.pos_downstreams
        while recepts:
          if len(recepts) > 1:
            raise ValueError("Can't automatically find neighbors for {},"
                             " which has multiple downstreams. You should"
                             " assign specific neighbors for {}."
                             .format(pre.get_alias(), source))
          pre = recepts[0]
          nbrs.append(pre.get_alias())
          hops.append(pre.shape[-1])
          recepts = pre.pos_downstreams
      n_neighbors = []
      for idx in range(len(nbrs)):
        n_neighbors.append(hops[idx])
      return EgoGraph(data_dict[source],
                      [data_dict[nbr] for nbr in nbrs],
                      [(self._dag.get_node(v).type, _get_feat_spec(v)) for v in [source] + nbrs],
                      n_neighbors)
function_tokens: def get_egograph ( self , source , neighbors = None ) : data_dict = self . get_data_dict ( ) def _get_feat_spec ( alias ) : node = self . _dag . get_node ( alias ) decoder = node . decoder return decoder . feature_spec source_node = self . _dag . get_node ( source ) nbrs = [ ] hops = [ ] if neighbors : # Use specified neighbors to construct EgoGraph. if not isinstance ( neighbors , list ) : raise ValueError ( "`neighbors` should be a list of alias" ) pre = source_node for nbr in neighbors : nbr_node = self . _dag . get_node ( nbr ) if not nbr_node in pre . pos_downstreams + pre . neg_downstreams : raise ValueError ( "{} is not the downstream of {}." . format ( nbr_node . get_alias ( ) , pre . get_alias ( ) ) ) nbrs . append ( nbr_node . get_alias ( ) ) hops . append ( nbr_node . shape [ - 1 ] ) pre = nbr_node else : # Use default receptive neighbors to construct EgoGraph. pre = source_node recepts = source_node . pos_downstreams while recepts : if len ( recepts ) > 1 : raise ValueError ( "Can't automatically find neighbors for {}," " which has multiple downstreams. You should" " assign specific neighbors for {}." . format ( pre . get_alias ( ) , source ) ) pre = recepts [ 0 ] nbrs . append ( pre . get_alias ( ) ) hops . append ( pre . shape [ - 1 ] ) recepts = pre . pos_downstreams n_neighbors = [ ] for idx in range ( len ( nbrs ) ) : n_neighbors . append ( hops [ idx ] ) return EgoGraph ( data_dict [ source ] , [ data_dict [ nbr ] for nbr in nbrs ] , [ ( self . _dag . get_node ( v ) . type , _get_feat_spec ( v ) ) for v in [ source ] + nbrs ] , n_neighbors )