Constant
¶
Bases: BaseTransform
Adds a constant value to the node features of each node.
This is a common way to give features to the nodes of a graph that has none.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
The value to add. Default: |
1.0
|
cat
|
bool
|
If |
True
|
Example:
graph = GraphData(edge_index=mx.array([[0, 1], [1, 2]]))
graph = Constant()(graph)
graph.node_features
# mx.array([[1.0], [1.0], [1.0]])
Methods:
| Name | Description |
|---|---|
process |
Adds the constant column to the node features of |
Source code in mlx_graphs/transforms/features.py
process
¶
Adds the constant column to the node features of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphData
|
The graph to transform. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph with the updated |
Source code in mlx_graphs/transforms/features.py
from mlx_graphs.transforms import Constant · mlx_graphs/transforms/features.py