adam.model.tree
===============

.. py:module:: adam.model.tree


Classes
-------

.. autoapisummary::

   adam.model.tree.Node
   adam.model.tree.Tree


Module Contents
---------------

.. py:class:: Node

   The node class


   .. py:attribute:: name
      :type:  str


   .. py:attribute:: link
      :type:  adam.model.abc_factories.Link


   .. py:attribute:: arcs
      :type:  list[adam.model.abc_factories.Joint]


   .. py:attribute:: children
      :type:  list[Node]


   .. py:attribute:: parent
      :type:  Union[adam.model.abc_factories.Link, None]
      :value: None



   .. py:attribute:: parent_arc
      :type:  Union[adam.model.abc_factories.Joint, None]
      :value: None



   .. py:method:: __hash__() -> int


   .. py:method:: get_elements() -> tuple[adam.model.abc_factories.Link, adam.model.abc_factories.Joint, adam.model.abc_factories.Link]

      returns the node with its parent arc and parent link

      :returns: the node, the parent_arc, the parent_link
      :rtype: tuple[Link, Joint, Link]



.. py:class:: Tree

   Bases: :py:obj:`Iterable`


   The directed tree class


   .. py:attribute:: graph
      :type:  dict[str, Node]


   .. py:attribute:: root
      :type:  str


   .. py:method:: __post_init__()


   .. py:method:: build_tree(links: list[adam.model.abc_factories.Link], joints: list[adam.model.abc_factories.Joint]) -> Tree
      :staticmethod:


      builds the tree from the connectivity of the elements

      :param links:
      :type links: list[Link]
      :param joints:
      :type joints: list[Joint]

      :returns: the directed tree
      :rtype: Tree



   .. py:method:: print(root)

      prints the tree

      :param root: the root of the tree
      :type root: str



   .. py:method:: get_ordered_nodes_list(start: str) -> list[str]

      get the ordered list of the nodes, given the connectivity

      :param start: the start node
      :type start: str

      :returns: the ordered list
      :rtype: list[str]



   .. py:method:: get_children(node: Node, list: Tree.get_children.list)
      :classmethod:


      Recursive method that finds children of child of child
      :param node: the analized node
      :type node: Node
      :param list: the list of the children that needs to be filled
      :type list: list



   .. py:method:: get_idx_from_name(name: str) -> int

      :param name: node name
      :type name: str

      :returns: the index of the node in the ordered list
      :rtype: int



   .. py:method:: get_name_from_idx(idx: int) -> str

      :param idx: the index in the ordered list
      :type idx: int

      :returns: the corresponding node name
      :rtype: str



   .. py:method:: get_node_from_name(name: str) -> Node

      :param name: the node name
      :type name: str

      :returns: the node istance
      :rtype: Node



   .. py:method:: __iter__() -> Iterator[Node]

      This method allows to iterate on the model
      :returns: the node istance
      :rtype: Node

      :Yields: *Iterator[Node]* -- the list of the nodes



   .. py:method:: __reversed__() -> Iterator[Node]

      :returns: Node

      :Yields: *Iterator[Node]* -- the reversed nodes list



   .. py:method:: __getitem__(key) -> Node

      get the item at key in the model

      :param key: _description_
      :type key: Union[int, Slice]

      :returns: _description_
      :rtype: Node



   .. py:method:: __len__() -> int

      :returns: the length of the model
      :rtype: int



