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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
copy Link
copy()
Deep copy of the tree.
Source code in src/phyllotaxis_analysis/tree/tree.py
622 623 624 625 |
|
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 |
|
getMaxLevel Link
getMaxLevel()
get the maximum level of leaves.
Source code in src/phyllotaxis_analysis/n_admissible_tree.py
70 71 72 73 74 |
|
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 |
|
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 |
Source code in src/phyllotaxis_analysis/tree/tree.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
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 |
|
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 |
|
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 |
|
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 |
|
is_valid Link
is_valid()
Checks if the object's state is valid.
Returns:
Type | Description |
---|---|
bool
|
|
Source code in src/phyllotaxis_analysis/tree/tree.py
190 191 192 193 194 195 196 197 198 199 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|