Skip to content

n_admissible_tree

phyllotaxis_analysis.n_admissible_tree Link

nAdmissibleTree Link

nAdmissibleTree()

Bases: PropertyTree

A class that adds some methods to PropertyTree to construct and explore an n-admissible tree.

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
10
11
12
def __init__(self):
    self.maxLevel = -1
    PropertyTree.__init__(self)

addChild Link

addChild(parent, value, level, pbAngle=None, logPbAngle=None, questionMark=False, orderIndex=None)

Add child with properties to the tree.

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    def addChild(self, parent, value, level, pbAngle = None, logPbAngle = None, questionMark = False, orderIndex = None):
        """
        Add child with properties to the tree.
        """
        for childId in self.children(parent):
            prop = self.get_vertex_property(childId)
            if ( prop["value"] == value) and  (prop["level"] == level) :
#                print "Already in the tree"
                return childId
                break
        else:
            if level > self.maxLevel:
                self.maxLevel = level
            return self.add_child(parent, value = value, level = level, nodePrb = pbAngle, nodeLogProb = logPbAngle, questionMark = questionMark, orderIndex = orderIndex)

addListValueLevelProb Link

addListValueLevelProb(currentId, ListValueLevel)

add vertexes given their ids and values to a vertex and updates the probability and order index of the vetex

:Parameters: - currentID - vertex id to which new vertexes should be added - ListValueLevel - list of values, levels, probabilities, log of probabilities, and order indexes of children

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
29
30
31
32
33
34
35
36
37
38
def addListValueLevelProb(self, currentId, ListValueLevel):
    """
    add vertexes given their ids and values to a vertex and updates the probability and order index of the vetex

    :Parameters:
    -    currentID    -    vertex id to which new vertexes should be added 
    -    ListValueLevel    -    list of values, levels, probabilities, log of probabilities, and order indexes of children  
    """
    for node in ListValueLevel:            
        currentId = self.addChild(parent = currentId, value = node[0], level = node[1], pbAngle = node[2], logPbAngle = node[3], orderIndex = node[4])

add_child Link

add_child(parent, child=None, **properties)

Add a child at the end of children

:param parent: The parent identifier. :param child: The child identifier.

:returns: vertex id

Source code in src/phyllotaxis_analysis/tree/tree.py
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
def add_child(self, parent, child=None, **properties):
    '''
    Add a child at the end of children

    :param parent: The parent identifier.
    :param child: The child identifier.

    :returns: vertex id
    '''

    child = super(PropertyTree, self).add_child(parent, child)

    # Update the properties
    self._add_vertex_properties(child, properties)

    return child

add_child_tree Link

add_child_tree(parent, tree)

Add a tree after the children of the parent vertex. Complexity have to be O(1) if tree == sub_tree()

:param parent: vertex identifier :param tree: a rooted tree

Source code in src/phyllotaxis_analysis/tree/tree.py
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
def add_child_tree(self, parent, tree):
    """
    Add a tree after the children of the parent vertex.
    Complexity have to be O(1) if tree == sub_tree()

    :param parent: vertex identifier
    :param tree: a rooted tree
    """
    treeid_id = super(PropertyTree, self).add_child_tree(parent, tree)
    for tid, vid in treeid_id.items():
        for name in tree.properties():
            v = tree.property(name).get(tid)
            if v is not None:
                self._properties[name][vid] = v

    return treeid_id

add_property Link

add_property(property_name)

Add a new map between vid and a data Do not fill this property for any vertex

Source code in src/phyllotaxis_analysis/tree/tree.py
878
879
880
881
882
883
def add_property(self, property_name):
    """
    Add a new map between vid and a data
    Do not fill this property for any vertex
    """
    self._properties[property_name] = {}

add_vertex Link

add_vertex(vid=None)

Add a vertex to the graph.

:param vid: the id of the vertex to be added. :type vid: vid :returns: the vid of the added vertex :rtype: vid

Source code in src/phyllotaxis_analysis/tree/tree.py
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
def add_vertex(self, vid=None):
    """
    Add a vertex to the graph.

    :param vid: the id of the vertex to be added.
    :type vid: vid
    :returns: the vid of the added vertex
    :rtype: vid
    """
    if vid is None:
        vid = self._id + 1
        self._id = vid
    elif vid <= self._id:
        raise InvalidVertex(f'Vertex identifier already used: {vid}')
    else:
        self._id = vid

    self._parent[vid] = None
    return vid

allPathsAll Link

allPathsAll()

allPathsAll returns a list of values, probabilities , question marks, as well as the total logarithmic probability of all the vertexes on the paths from leaves to the root.

:Returns: - [valueList, probList ,questionList, logProb] - list of lists of values, probability , question marks, as well as the total logarithmic probability of all the vertexes on the paths from leaves to the root

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def allPathsAll(self):
    """
    `allPathsAll` returns a list of values, probabilities , question marks, as well as the total logarithmic probability of all the vertexes on the paths from leaves to the root.

    :Returns:
    -    `[valueList, probList ,questionList, logProb]`    -    list of lists of values, probability , question marks, as well as the total logarithmic probability of all the vertexes on the paths from leaves to the root
    """
    for vid in self.vertices():
        if self.is_leaf(vid):
            valueList = list()
            probList = list()
            questionList = list()
            logProb = 0.0
            while not (vid == self.root):
                valueList.append(self.get_vertex_property(vid)["value"])
                probList.append(self.get_vertex_property(vid)["nodePrb"])
                logProb += self.get_vertex_property(vid)["nodeLogProb"]
                if self.get_vertex_property(vid)["questionMark"]:
                    questionList.append([self.get_vertex_property(vid)["value"], self.get_vertex_property(vid)["level"] ])
                vid = self.parent(vid)
            valueList.reverse()
            probList.reverse()
            questionList.reverse()
            yield [valueList, probList ,questionList, logProb]

children Link

children(vid)

Return the children of vid.

:returns: list of vertex identifiers

Source code in src/phyllotaxis_analysis/tree/tree.py
308
309
310
311
312
313
314
315
316
317
def children(self, vid):
    """
    Return the children of `vid`.

    :returns: list of vertex identifiers
    """
    if vid not in self:
        raise InvalidVertex(vid)

    return list(self._children.get(vid, []))

clear Link

clear()

Remove all vertices and edges from the graph.

Source code in src/phyllotaxis_analysis/tree/tree.py
248
249
250
251
252
253
254
def clear(self):
    """
    Remove all vertices and edges from the graph.
    """
    self._children.clear()
    self._parent.clear()
    self._parent[self._root] = None

copy Link

copy()

Deep copy of the tree.

Source code in src/phyllotaxis_analysis/tree/tree.py
622
623
624
625
def copy(self):
    """ Deep copy of the tree.
    """
    return deepcopy(self)

edges_iter Link

edges_iter()

Iter on the edges of the tree.

Source code in src/phyllotaxis_analysis/tree/tree.py
201
202
203
204
205
def edges_iter(self):
    """
    Iter on the edges of the tree.
    """
    return ((parent, child) for child, parent in self._parent.items())

getMaxLevel Link

getMaxLevel()

get the maximum level of leaves.

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
70
71
72
73
74
def getMaxLevel(self):
    """
    get the maximum level of leaves.
    """
    return self.maxLevel     

get_vertex_property Link

get_vertex_property(vid)

Returns all the properties defined on a vertex.

Source code in src/phyllotaxis_analysis/tree/tree.py
917
918
919
920
921
def get_vertex_property(self, vid):
    """ Returns all the properties defined on a vertex.
    """
    p = self.properties()
    return dict((name, p[name][vid]) for name in p if vid in p[name])

has_vertex Link

has_vertex(vid)

Determines whether a given vertex is in the graph.

Parameters:

Name Type Description Default
vid int or str

The identifier of the vertex to be checked for existence in the graph.

required

Returns:

Type Description
bool

Returns True if the vertex is present in the graph, False otherwise.

Source code in src/phyllotaxis_analysis/tree/tree.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
def has_vertex(self, vid):
    """Determines whether a given vertex is in the graph.

    Parameters
    ----------
    vid : int or str
        The identifier of the vertex to be checked for existence in the graph.

    Returns
    -------
    bool
        Returns ``True`` if the vertex is present in the graph, ``False`` otherwise.
    """
    return vid in self._parent

insert_parent Link

insert_parent(vid, parent_id=None, **properties)

Insert parent_id between vid and its actual parent. Inherit of the complex of the parent of vid.

:Parameters: - vid: a vertex identifier - parent_id: a vertex identifier

Source code in src/phyllotaxis_analysis/tree/tree.py
726
727
728
729
730
731
732
733
734
735
736
737
738
739
def insert_parent(self, vid, parent_id=None, **properties):
    '''
    Insert parent_id between vid and its actual parent.
    Inherit of the complex of the parent of vid.

    :Parameters:
     - `vid`: a vertex identifier
     - `parent_id`: a vertex identifier
    '''

    parent_id = super(PropertyTree, self).insert_parent(vid, parent_id)
    self._add_vertex_properties(parent_id, properties)

    return parent_id

insert_sibling Link

insert_sibling(vid_1, vid_2=None, **properties)

Insert vid2 before vid1.

:Parameters: - vid1: a vertex identifier - vid2: the vertex to insert

Source code in src/phyllotaxis_analysis/tree/tree.py
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
def insert_sibling(self, vid_1, vid_2=None, **properties):
    '''
    Insert vid2 before vid1.

    :Parameters:
     - `vid1`: a vertex identifier
     - `vid2`: the vertex to insert
    '''

    vid_2 = super(PropertyTree, self).insert_sibling(vid_1, vid_2)

    # Update the properties
    self._add_vertex_properties(vid_2, properties)

    return vid_2

insert_sibling_tree Link

insert_sibling_tree(vid, tree)

Insert a tree before the vid. vid and the root of the tree are siblings. Complexity have to be O(1) if tree comes from the actual tree ( tree= self.sub_tree() )

:param vid: vertex identifier :param tree: a rooted tree

Source code in src/phyllotaxis_analysis/tree/tree.py
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
def insert_sibling_tree(self, vid, tree):
    """
    Insert a tree before the vid.
    vid and the root of the tree are siblings.
    Complexity have to be O(1) if tree comes from the actual tree
    ( tree= self.sub_tree() )

    :param vid: vertex identifier
    :param tree: a rooted tree
    """
    treeid_id = super(PropertyTree, self).insert_sibling_tree(vid, tree)
    for tid, vid in treeid_id.items():
        for name in tree.properties():
            v = tree.property(name).get(tid)
            if v is not None:
                self._properties[name][vid] = v

    return treeid_id

is_leaf Link

is_leaf(vid)

Test if vid is a leaf.

:returns: bool

Source code in src/phyllotaxis_analysis/tree/tree.py
355
356
357
358
359
360
361
def is_leaf(self, vid):
    """
    Test if `vid` is a leaf.

    :returns: bool
    """
    return self.nb_children(vid) == 0

is_valid Link

is_valid()

Checks if the object's state is valid.

Returns:

Type Description
bool

True if the object is in a valid state, False otherwise.

Source code in src/phyllotaxis_analysis/tree/tree.py
190
191
192
193
194
195
196
197
198
199
def is_valid(self):
    """Checks if the object's state is valid.

    Returns
    -------
    bool
        ``True`` if the object is in a valid state, ``False`` otherwise.
    """
    # TODO
    return True

leaves Link

leaves()

return the list of leaves of the n-admisisble tree.

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
40
41
42
43
44
def leaves(self):
    """
    return the list of leaves of the n-admisisble tree.
    """
    return [vid for vid in self.vertices() if self.is_leaf(vid)]

leavesLast Link

leavesLast(seqLen)

return the leaves of the tree whose level is equal to a given value.

:Parameters: - seqlen - an integer

:Returns: - list of leaves whose level is equal to seqLen

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
58
59
60
61
62
63
64
65
66
67
68
def leavesLast(self, seqLen):
    """
    return the leaves of the tree whose level is equal to a given value.

    :Parameters:
    -    `seqlen`    -    an integer

    :Returns:
    -    list of leaves whose level is equal to `seqLen`
    """
    return [vid for vid in self.vertices() if (vid != self.root) and ( self.get_vertex_property(vid)["level"] == seqLen  ) ]

leavesNotLast Link

leavesNotLast(seqLen)

return the leaves of the tree whose level is different from a given value.

:Parameters: - seqlen - an integer

:Returns: - list of leaves whose level is not equal to seqLen

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
46
47
48
49
50
51
52
53
54
55
56
def leavesNotLast(self, seqLen):
    """
    return the leaves of the tree whose level is different from a given value.

    :Parameters:
    -    `seqlen`    -    an integer

    :Returns:
    -    list of leaves whose level is not equal to `seqLen`
    """
    return [vid for vid in self.vertices() if (  self.is_leaf(vid)  and (self.get_vertex_property(vid)["level"] != seqLen  )) ]

nb_children Link

nb_children(vid)

Return the number of children of vid.

:returns: int

Source code in src/phyllotaxis_analysis/tree/tree.py
319
320
321
322
323
324
325
326
327
328
def nb_children(self, vid):
    """
    Return the number of children of `vid`.

    :returns: int
    """
    if vid not in self:
        raise InvalidVertex(vid)

    return len(self._children.get(vid, []))

nb_siblings Link

nb_siblings(vid)

Return the number of siblings of vid.

:returns: int

Source code in src/phyllotaxis_analysis/tree/tree.py
347
348
349
350
351
352
353
def nb_siblings(self, vid):
    """
    Return the number of siblings of `vid`.

    :returns: int
    """
    return len(self.siblings(vid))

nb_vertices Link

nb_vertices()

Returns the number of vertices in the graph.

Returns:

Type Description
int

The number of vertices in the graph.

See Also

nb_edges : Returns the number of edges in the graph.

Examples:

>>> from phyllotaxis_analysis.tree import Tree
>>> g = Tree()  # initialize a new tree with a single node (the root)
>>> g.add_vertex()  # add a first vertices
>>> g.add_vertex()  # add a second vertices
>>> g.nb_vertices()
3
Source code in src/phyllotaxis_analysis/tree/tree.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
def nb_vertices(self):
    """Returns the number of vertices in the graph.

    Returns
    -------
    int
        The number of vertices in the graph.

    See Also
    --------
    nb_edges : Returns the number of edges in the graph.

    Examples
    --------
    >>> from phyllotaxis_analysis.tree import Tree
    >>> g = Tree()  # initialize a new tree with a single node (the root)
    >>> g.add_vertex()  # add a first vertices
    >>> g.add_vertex()  # add a second vertices
    >>> g.nb_vertices()
    3
    """
    return len(self._parent)

parent Link

parent(vid)

Return the parent of vid.

:returns: vertex identifier or None if vid is the root.

Source code in src/phyllotaxis_analysis/tree/tree.py
297
298
299
300
301
302
303
304
305
306
def parent(self, vid):
    """
    Return the parent of `vid`.

    :returns: vertex identifier or None if vid is the root.
    """
    try:
        return self._parent[vid]
    except KeyError:
        raise InvalidVertex(vid)

pathToRoot Link

pathToRoot(vid)

return list of values of vertexes on the path from a given vertex to the root.

:Parameters: - vid - a vertex id

:Returns: valueList - list of values of vertexes on the path from the vertex to the root.

Source code in src/phyllotaxis_analysis/n_admissible_tree.py
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def pathToRoot(self, vid):
    """
    return list of values of vertexes on the path from a given vertex to the root.

    :Parameters:
    -   `vid`    -    a vertex id 

    :Returns:
    `valueList`    -    list of values of vertexes on the path from the `vertex` to the root.
    """

    valueList = list()
    while not (vid == self.root):
        valueList.append(self.get_vertex_property(vid)["value"]) 
        vid = self.parent(vid)
    valueList.reverse()
    return valueList

properties Link

properties()

Returns all the property maps contain in the graph.

Source code in src/phyllotaxis_analysis/tree/tree.py
891
892
893
894
895
def properties(self):
    """
    Returns all the property maps contain in the graph.
    """
    return self._properties

property Link

property(name)

Returns the property map between the vid and the data. :returns: dict of {vid:data}

Source code in src/phyllotaxis_analysis/tree/tree.py
871
872
873
874
875
876
def property(self, name):
    '''
    Returns the property map between the vid and the data.
    :returns:  dict of {vid:data}
    '''
    return self._properties.get(name, {})

property_names Link

property_names()

names of all property maps. Properties are defined only on vertices, even edge properties. return iter of names

Source code in src/phyllotaxis_analysis/tree/tree.py
855
856
857
858
859
860
861
def property_names(self):
    '''
    names of all property maps.
    Properties are defined only on vertices, even edge properties.
    return iter of names
    '''
    return self._properties.keys()

property_names_iter Link

property_names_iter()

iter on names of all property maps. Properties are defined only on vertices, even edge properties. return iter of names

Source code in src/phyllotaxis_analysis/tree/tree.py
863
864
865
866
867
868
869
def property_names_iter(self):
    '''
    iter on names of all property maps.
    Properties are defined only on vertices, even edge properties.
    return iter of names
    '''
    return iter(self._properties.keys())

remove_property Link

remove_property(property_name)

Remove the property map called property_name from the graph.

Source code in src/phyllotaxis_analysis/tree/tree.py
885
886
887
888
889
def remove_property(self, property_name):
    """
    Remove the property map called property_name from the graph.
    """
    del self._properties[property_name]

remove_tree Link

remove_tree(vid)

Remove the sub tree rooted on vid.

:returns: bool

Source code in src/phyllotaxis_analysis/tree/tree.py
840
841
842
843
844
845
846
847
848
849
def remove_tree(self, vid):
    """
    Remove the sub tree rooted on `vid`.

    :returns: bool
    """
    vids = super(PropertyTree, self).remove_tree(vid)
    for vid in vids:
        self._remove_vertex_properties(vid)
    return vids

remove_vertex Link

remove_vertex(vid, reparent_child=False)

remove a specified vertex of the graph remove all the edges attached to it

:param vid: the id of the vertex to remove :type vid: vid

Source code in src/phyllotaxis_analysis/tree/tree.py
682
683
684
685
686
687
688
689
690
691
def remove_vertex(self, vid, reparent_child=False):
    """
    remove a specified vertex of the graph
    remove all the edges attached to it

    :param vid: the id of the vertex to remove
    :type vid: vid
    """
    vid = super(PropertyTree, self).remove_vertex(vid, reparent_child=reparent_child)
    self._remove_vertex_properties(vid)

replace_parent Link

replace_parent(vid, new_parent_id)

Change the parent of vid to new_parent_id. vid parent is removed.

:param vid: vertex to change the parent of :param new_parent_id: new parent

Source code in src/phyllotaxis_analysis/tree/tree.py
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
def replace_parent(self, vid, new_parent_id):
    """
    Change the parent of `vid` to `new_parent_id`.
    vid parent is removed.

    :param vid: vertex to change the parent of
    :param new_parent_id: new parent
    """
    if vid not in self:
        raise InvalidVertex(vid)
    if new_parent_id not in self:
        raise InvalidVertex(new_parent_id)

    old_parent = self.parent(vid)
    if old_parent is None:
        raise InvalidVertex("Cannot replace parent of the root")

    # Update parent
    self._parent[vid] = new_parent_id

    # Update children
    self._children[old_parent].remove(vid)
    if new_parent_id in self._children:
        self._children[new_parent_id].append(vid)
    else:
        self._children[new_parent_id] = [vid]

set_root Link

set_root(vid)

Set the root of the tree.

Source code in src/phyllotaxis_analysis/tree/tree.py
283
284
285
286
287
288
289
def set_root(self, vid):
    """
    Set the root of the tree.
    """
    if vid not in self:
        self.add_vertex(vid)
    self._root = vid

siblings Link

siblings(vid)

Return the siblings of vid.

:returns: list of vertex identifiers

Source code in src/phyllotaxis_analysis/tree/tree.py
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
def siblings(self, vid):
    """
    Return the siblings of `vid`.

    :returns: list of vertex identifiers
    """
    if vid not in self:
        raise InvalidVertex(vid)

    parent = self.parent(vid)
    if parent is None:
        return []
    else:
        sibs = list(self.children(parent))
        sibs.remove(vid)
        return sibs

sub_tree Link

sub_tree(vid, copy=True)

Return the subtree rooted on vid.

The induced subtree of the tree has the vertices in the ancestors of vid.

:Parameters: - vid: A vertex of the original tree. - copy:
If True, return a new tree holding the subtree. If False, the subtree is created using the original tree by deleting all vertices not in the subtree.

:returns: A sub tree of the tree. If copy=True, a new Tree is returned. Else the subtree is created inplace by modifying the original tree.

Source code in src/phyllotaxis_analysis/tree/tree.py
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
def sub_tree(self, vid, copy=True):
    """Return the subtree rooted on `vid`.

    The induced subtree of the tree has the vertices in the ancestors of vid.

    :Parameters:
      - `vid`: A vertex of the original tree.
      - `copy`:  
        If True, return a new tree holding the subtree. If False, the subtree is
        created using the original tree by deleting all vertices not in the subtree.

    :returns: A sub tree of the tree. If copy=True, a new Tree is returned. 
        Else the subtree is created inplace by modifying the original tree. 
    """
    from phyllotaxis_analysis.tree import pre_order
    if not copy:
        # remove all vertices not in the sub_tree
        bunch = set(pre_order(self, vid))
        remove_bunch = set(self) - bunch

        for vid in remove_bunch:
            self._remove_vertex_properties(vid)

            # remove parent edge
            pid = self.parent(vid)
            if pid is not None:
                self._children[pid].remove(vid)
                del self._parent[vid]
            # remove children edges
            for cid in self.children(vid):
                self._parent[cid] = None
            if vid in self._children:
                del self._children[vid]

        self.root = vid
        return self
    else:
        treeid_id = {}
        tree = self.__class__()
        tree.root = 0

        for name in self.properties():
            tree.add_property(name)

        treeid_id[vid] = tree.root
        tree._add_vertex_properties(tree.root, self.get_vertex_property(vid))
        subtree = pre_order(self, vid)
        next(subtree)
        for vid in subtree:
            pid = self.parent(vid)
            if pid is not None:
                parent = treeid_id[pid]
                v = tree.add_child(parent)
                treeid_id[vid] = v

            tree._add_vertex_properties(v, self.get_vertex_property(vid))

        return tree

vertices Link

vertices()

Returns the list of vertices in the graph.

Returns:

Type Description
list

A list of the vertices in the graph.

Source code in src/phyllotaxis_analysis/tree/tree.py
155
156
157
158
159
160
161
162
163
def vertices(self):
    """Returns the list of vertices in the graph.

    Returns
    -------
    list
        A list of the vertices in the graph.
    """
    return list(self.vertices_iter())

vertices_iter Link

vertices_iter()

Generates an iterator for the vertices in the graph.

This method is a generator that yields each vertex in the graph as a string, which corresponds to the key of the vertex in the internal dictionary representation of the graph. The order in which vertices are returned by this iterator is not guaranteed to be consistent between different calls or even different yields.

Returns:

Type Description
iterator

An iterator that produces the vertices of the graph as strings.

Source code in src/phyllotaxis_analysis/tree/tree.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
def vertices_iter(self):
    """Generates an iterator for the vertices in the graph.

    This method is a generator that yields each vertex in the graph as a string,
    which corresponds to the key of the vertex in the internal dictionary representation
    of the graph. The order in which vertices are returned by this iterator is not
    guaranteed to be consistent between different calls or even different yields.

    Returns
    -------
    iterator
        An iterator that produces the vertices of the graph as strings.
    """
    return iter(self._parent.keys())