adam.model.tree#

Classes#

Node

The node class

Tree

The directed tree class

Module Contents#

class adam.model.tree.Node[source]#

The node class

name: str[source]#
arcs: List[adam.model.abc_factories.Joint][source]#
children: List[Node][source]#
parent: adam.model.abc_factories.Link | None = None[source]#
parent_arc: adam.model.abc_factories.Joint | None = None[source]#
__hash__() int[source]#
get_elements() Tuple[adam.model.abc_factories.Link, adam.model.abc_factories.Joint, adam.model.abc_factories.Link][source]#

returns the node with its parent arc and parent link

Returns:

the node, the parent_arc, the parent_link

Return type:

Tuple[Link, Joint, Link]

class adam.model.tree.Tree[source]#

Bases: Iterable

The directed tree class

graph: Dict[source]#
root: str[source]#
__post_init__()[source]#
static build_tree(links: List[adam.model.abc_factories.Link], joints: List[adam.model.abc_factories.Joint]) Tree[source]#

builds the tree from the connectivity of the elements

Parameters:
Returns:

the directed tree

Return type:

Tree

print(root)[source]#

prints the tree

Parameters:

root (str) – the root of the tree

get_ordered_nodes_list(start: str) List[str][source]#

get the ordered list of the nodes, given the connectivity

Parameters:

start (str) – the start node

Returns:

the ordered list

Return type:

List[str]

classmethod get_children(node: Node, list: List)[source]#

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

get_idx_from_name(name: str) int[source]#
Parameters:

name (str) – node name

Returns:

the index of the node in the ordered list

Return type:

int

get_name_from_idx(idx: int) str[source]#
Parameters:

idx (int) – the index in the ordered list

Returns:

the corresponding node name

Return type:

str

get_node_from_name(name: str) Node[source]#
Parameters:

name (str) – the node name

Returns:

the node istance

Return type:

Node

__iter__() Node[source]#

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

Yields:

Iterator[Node] – the list of the nodes

__reversed__() Node[source]#
Returns:

Node

Yields:

Iterator[Node] – the reversed nodes list

__getitem__(key) Node[source]#

get the item at key in the model

Parameters:

key (Union[int, Slice]) – _description_

Returns:

_description_

Return type:

Node

__len__() int[source]#
Returns:

the length of the model

Return type:

int