Node Class¶
The Forge Node class wraps around the igraph.Vertex
object that is initialized by the graphical encoding provided by the graph-core API.
forge.relay.graph.node.Node(graph: Graph, vertex: Union[igraph.Vertex, str])
¶
A wrapper around igraph.Vertex
for graph-encoded Relay expressions.
The Node
class provides a simplified API for working with graph vertices
in the context of the Forge Graph
it belongs to. It represents a single
vertex and encapsulates metadata, relationships, and attributes of the graph.
Initializes a Node instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph
|
Graph
|
The Forge graph to which this node belongs. |
required |
vertex
|
Union[Vertex, str]
|
The |
required |
graph: Graph = graph
instance-attribute
¶
name: str
property
¶
Retrieves the name of the node.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the node. |
type: str
property
¶
Retrieves the type of the node.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The type of the node (e.g. Sink, Call, Constant). |
shape: Union[Tuple[int], List[Tuple[int]]]
property
¶
Retrieves the shape(s) of the node's activation data.
Returns:
Type | Description |
---|---|
Union[Tuple[int], List[Tuple[int]]]
|
Union[Tuple[int], List[Tuple[int]]]: The shape or a list of shapes associated with the node. |
dtype: Union[str, List[str]]
property
¶
Retrieves the data type(s) of the node's activation data.
Returns:
Type | Description |
---|---|
Union[str, List[str]]
|
Union[str, List[str]]: The data type or a list of data types associated with the node. |
size: Union[Optional[int], List[Optional[int]]]
property
¶
Retrieves the size(s) of the node's activation data.
Returns:
Type | Description |
---|---|
Union[Optional[int], List[Optional[int]]]
|
Union[Optional[int], List[Optional[int]]]: The size or a list of sizes associated with the node. |
Note
- Size is the number of total elements, i.e. the reduced product of the shape
pred: List[Node]
property
¶
Retrieves the predecessor nodes in argument order.
Returns:
Type | Description |
---|---|
List[Node]
|
List[Node]: A list of predecessor nodes in argument order. |
succ: List[Node]
property
¶
Retrieves the successor nodes.
Returns:
Type | Description |
---|---|
List[Node]
|
List[Node]: A list of successor nodes. |
target_names: List[str]
property
¶
Retrieves the names of target nodes for outgoing edges.
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: A list of target node names. |
target_argidxs: List[int]
property
¶
Retrieves the argument indices for outgoing edges.
Returns:
Type | Description |
---|---|
List[int]
|
List[int]: A list of argument indices. |
target_details: Tuple[Tuple[str, ...], Tuple[int, ...]]
property
¶
Retrieves details of outgoing edges, including target names and argument indices.
Returns:
Type | Description |
---|---|
Tuple[Tuple[str, ...], Tuple[int, ...]]
|
Tuple[Tuple[str, ...], Tuple[int, ...]]: A tuple containing target names and argument indices. |
indegree: int
property
¶
Retrieves the in-degree of the node.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The number of incoming edges. |
outdegree: int
property
¶
Retrieves the out-degree of the node.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The number of outgoing edges. |
activation: ActivationMetaData
property
¶
Retrieves the activation metadata of the node.
Returns:
Name | Type | Description |
---|---|---|
ActivationMetaData |
ActivationMetaData
|
The activation metadata associated with the node. |
input_index: Optional[int]
property
¶
Retrieves the input index of the node, if applicable.
Returns:
Type | Description |
---|---|
Optional[int]
|
Optional[int]: The input index, or None if not applicable. |
tuple_index: Optional[int]
property
¶
Retrieves the tuple index of the node, if applicable.
Returns:
Type | Description |
---|---|
Optional[int]
|
Optional[int]: The tuple index, or None if not applicable. |
op_name: Optional[str]
property
¶
Retrieves the name of the operator associated with the node, if applicable.
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The operator name, or None if not applicable. |
op_attrs: Optional[str]
property
¶
Retrieves the attributes of the operator associated with the node, if applicable.
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The operator attributes, or None if not applicable. |
op_type: Optional[str]
property
¶
Retrieves the type of the operator associated with the node, if applicable.
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The operator type, or None if not applicable. |
layout: Optional[str]
property
¶
Retrieves the layout associated with the node, if applicable.
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The layout, or None if not applicable. |
calib: Optional[CalibrationMetaData]
property
¶
Retrieves the calibration metadata of the node, if applicable.
Returns:
Type | Description |
---|---|
Optional[CalibrationMetaData]
|
Optional[CalibrationMetaData]: The calibration metadata, or None if not applicable. |
data: Optional[np.ndarray]
property
¶
Retrieves the data associated with the node, if applicable.
Returns:
Type | Description |
---|---|
Optional[ndarray]
|
Optional[np.ndarray]: The data, or None if not applicable. |
ivertex: igraph.Vertex
property
¶
Retrieves the underlying igraph.Vertex for this node.
Returns:
Type | Description |
---|---|
Vertex
|
igraph.Vertex: The underlying vertex. |
set_name(name) -> None
¶
Sets the name of the node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The new name for the node. |
required |
set_data(data: np.ndarray) -> None
¶
Sets the data for the node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ndarray
|
The data to associate with the node. |
required |
relay_var() -> Relay.Var.obj
¶
Expresses the node as a Relay variable.
Returns:
Type | Description |
---|---|
obj
|
Relay.Var.obj: The Relay variable representation of the node. |
_find_ivertex(name: str) -> igraph.Vertex
¶
Finds the igraph.Vertex by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the vertex to find. |
required |
Returns:
Type | Description |
---|---|
Vertex
|
igraph.Vertex: The found vertex. |
_init_node(vertex: Union[igraph.Vertex, str]) -> Node
¶
Initializes a node from an igraph.Vertex or its name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vertex
|
Union[Vertex, str]
|
The vertex or its name. |
required |
Returns:
Name | Type | Description |
---|---|---|
Node |
Node
|
The initialized Node. |
_out_iedges() -> List[igraph.Edge]
¶
Retrieves the outgoing edges from the node.
Returns:
Type | Description |
---|---|
List[Edge]
|
List[igraph.Edge]: A list of outgoing edges. |
_iter_pred()
¶
Iterates over predecessor nodes.
Returns:
Type | Description |
---|---|
Iterator[Node]: An iterator over predecessor nodes. |
_iter_succ()
¶
Iterates over successor nodes.
Returns:
Type | Description |
---|---|
Iterator[Node]: An iterator over successor nodes. |
__repr__() -> str
¶
Generates a string representation of the node.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string describing the node. |
__getitem__(key) -> Any
¶
Retrieves a node attribute by key using igraph.Vertex
API syntax.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The key of the attribute. |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The value of the attribute. |
__setitem__(key, val) -> None
¶
Sets a node attribute by key using igraph.Vertex
API syntax.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The key of the attribute. |
required |
val
|
Any
|
The value to set for the attribute. |
required |