node_attrs_to_torch_tensor
Returns node attributes of the graph in the form of a torch tensor.
sasviya.network.utils.conversions.node_attrs_to_torch_tensor(g, node_attrs)
Parameters
- g : SAS graph object
-
Specifies the input graph to assess.
- node_attrs : str or iterable of str or ‘ALL’
-
Specifies the node attributes to include. The value can be a single string, a list of strings, or ‘ALL’ to include all node attributes. If any of the specified node attributes are not numeric, a ValueError is raised.
Returns
- torch.Tensor
-
Returns a torch tensor of the size (number of nodes, number of node attributes).
Examples
import dgl
import torch
g = dgl.data.CoraGraphDataset()[0]
G = sasnet.from_dgl(g,create_using=sasnet.ImmutableGraph)
print(sasnet.node_attr_to_torch_tensor(G,node_attrs='ALL'))
Last updated: July 28, 2026