ragraph.node
¶
Node class module¶
Node
¶
Node(
name: Optional[str] = None,
parent: Optional[Node] = None,
children: Optional[Iterable[Node]] = None,
is_bus: bool = False,
kind: str = "node",
labels: Optional[List[str]] = None,
weights: Optional[Dict[str, Union[int, float]]] = None,
annotations: Union[
Annotations, Dict[str, Any], None
] = None,
uuid: Optional[Union[str, UUID]] = None,
)
Bases: Metadata
Generic node class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
Instance name. Given a UUID if none provided. |
None
|
parent
|
Optional[Node]
|
Parent node. |
None
|
children
|
Optional[Iterable[Node]]
|
List of child nodes. |
None
|
kind
|
str
|
Kind or main category of this instance. |
'node'
|
labels
|
Optional[List[str]]
|
Labels categorizing this instance. |
None
|
weights
|
Optional[Dict[str, Union[int, float]]]
|
Dictionary of weights attached to this instance. |
None
|
annotations
|
Union[Annotations, Dict[str, Any], None]
|
Miscellaneous properties of this instance. |
None
|
uuid
|
Optional[Union[str, UUID]]
|
Fixed UUID if desired, generated when left set to None. |
None
|
Source code in ragraph/node.py
depth
property
¶
Depth of this node, e.g. the number of levels from the node to the root.
descendant_gen
property
¶
descendant_gen: Generator[Node, None, None]
Yield all descendants of this node.
json_dict
property
¶
JSON dictionary representation.
Returns:
Name | Type | Description |
---|---|---|
name |
Dict[str, Any]
|
Name as str. |
parent |
Dict[str, Any]
|
Parent name (not Node) as str. |
children |
Dict[str, Any]
|
Children names (not Nodes) as str. |
is_bus |
Dict[str, Any]
|
is_bus as bool. |
kind |
Dict[str, Any]
|
Kind as str. |
labels |
Dict[str, Any]
|
Labels as a list of strings. |
weights |
Dict[str, Any]
|
Weights as dict. |
annotations |
Dict[str, Any]
|
Annotations as per
|
width
property
¶
Width of this node, e.g. the number of leaf nodes in this node's branch.
as_dict
¶
Return a copy as a (serializable) dictionary.
Returns:
Name | Type | Description |
---|---|---|
name |
Dict[str, Any]
|
Name as str. |
parent |
Dict[str, Any]
|
Parent name or UUID (not Node) as str. |
children |
Dict[str, Any]
|
Children names (not Nodes) as str. |
is_bus |
Dict[str, Any]
|
is_bus as bool. |
kind |
Dict[str, Any]
|
Kind as str. |
labels |
Dict[str, Any]
|
Labels as a list of strings. |
weights |
Dict[str, Any]
|
Weights as dict. |
annotations |
Dict[str, Any]
|
Annotations as per
|
uuid |
Dict[str, Any]
|
UUID as str if toggled. |