def lineaged_vertex(self, fully_lineaged=False, as_ancestor=False, as_descendant=False, lineage_rank=1): """ Return ids of lineaged vertices, with differents type of lineage possible: - a full lineage, i.e. only vids with a lineage from the first to the last time-point (fully_lineaged=True); - a lineage over several ranks, i.e. only vids with a lineage from the vid to the vid+lineage_rank time-point (fully_lineaged=False, lineage_rank=int); - an 'ancestors' based lineage (as_ancestor = True), i.e. only vids lineaged as ancestor (over lineage_rank if not None); - an 'descendants' based lineage (as_ancestor = True), i.e. only vids lineaged as descendants (over lineage_rank if not None). :Parameter: fully_lineaged: (bool) : if True (and lineage_rank is None), return vertices lineaged from the first to the last time-point (or from vid_time_point to vid_time_point + lineage_rank), otherwise return vertices having at least a parent or a child(ren); as_parent: (bool) : if True, return vertices lineaged as parents; as_children: (bool) : if True, return vertices lineaged as children; - 'lineage_rank' (int): usefull if you want to check the lineage for a different rank than the rank-1 temporal neighborhood. """ if as_ancestor: vids_anc = self._lineaged_as_ancestor(time_point=None, rank=lineage_rank) else: vids_anc = self.vertices() if as_descendant: vids_desc = self._lineaged_as_descendant(time_point=None, rank=lineage_rank) else: vids_desc = self.vertices() if fully_lineaged: vids = self._fully_lineaged_vertex(time_point=None) else: vids = [ k for k in self.vertices() if ( exist_all_relative_at_rank(self, k, lineage_rank) or exist_all_relative_at_rank(self, k, -lineage_rank) ) ] return list(set(vids) & set(vids_anc) & set(vids_desc))
def _fully_lineaged_vertex(self, time_point=None): """ Return a list of fully lineaged vertex (from a given `time_point` if not None), i.e. lineaged from start to end. """ rank = self.nb_time_points - 1 flv = self.descendants([k for k in self.vertex_at_time(0) if exist_all_relative_at_rank(self, k, rank)], rank) if time_point is None: return flv else: return [vid for vid in flv if self.vertex_temporal_index(vid) == time_point]
def lineaged_vertex(self, fully_lineaged=False, as_ancestor=False, as_descendant=False, lineage_rank=1): """ Return ids of lineaged vertices, with differents type of lineage possible: - a full lineage, i.e. only vids with a lineage from the first to the last time-point (fully_lineaged=True); - a lineage over several ranks, i.e. only vids with a lineage from the vid to the vid+lineage_rank time-point (fully_lineaged=False, lineage_rank=int); - an 'ancestors' based lineage (as_ancestor = True), i.e. only vids lineaged as ancestor (over lineage_rank if not None); - an 'descendants' based lineage (as_ancestor = True), i.e. only vids lineaged as descendants (over lineage_rank if not None). :Parameter: fully_lineaged: (bool) : if True (and lineage_rank is None), return vertices lineaged from the first to the last time-point (or from vid_time_point to vid_time_point + lineage_rank), otherwise return vertices having at least a parent or a child(ren); as_parent: (bool) : if True, return vertices lineaged as parents; as_children: (bool) : if True, return vertices lineaged as children; - 'lineage_rank' (int): usefull if you want to check the lineage for a different rank than the rank-1 temporal neighborhood. """ if as_ancestor: vids_anc = self._lineaged_as_ancestor(time_point=None, rank=lineage_rank) else: vids_anc = self.vertices() if as_descendant: vids_desc = self._lineaged_as_descendant(time_point=None, rank=lineage_rank) else: vids_desc = self.vertices() if fully_lineaged: vids = self._fully_lineaged_vertex(time_point=None) else: vids = [ k for k in self.vertices() if (exist_all_relative_at_rank(self, k, lineage_rank) or exist_all_relative_at_rank(self, k, -lineage_rank)) ] return list(set(vids) & set(vids_anc) & set(vids_desc))
def _fully_lineaged_vertex(self, time_point=None): """ Return a list of fully lineaged vertex (from a given `time_point` if not None), i.e. lineaged from start to end. """ rank = self.nb_time_points - 1 flv = self.descendants([ k for k in self.vertex_at_time(0) if exist_all_relative_at_rank(self, k, rank) ], rank) if time_point is None: return flv else: return [ vid for vid in flv if self.vertex_temporal_index(vid) == time_point ]