# Heterograph models accounting for note attributes

From my understanding of the heterograph model:
https://docs.dgl.ai/tutorials/hetero/1_basics.html
The model provided does not support node features (the graph structure is what is input) as indicated by the following excerpt from the above tutorial:
“Create a simple GNN by stacking two `HeteroRGCNLayer` . Since the nodes do not have input features, make their embeddings trainable…”
Is there a model that considers input features, i.e., I can add features/properties to the node.

Thanks
Rajiv

You may find this example helpful: https://github.com/dmlc/dgl/tree/master/examples/pytorch/han.

The example works with a heterogeneous graph with one type of nodes and multiple types of edges and can be extended to a graph with multiple types of nodes. This example has considered initial node features for `DGLHeteroGraph`.

Thank you. I’ll go through the example.
Rajiv

Hi Mufei,
That you for that pointer. I did go through it and the metapath2vec paper. I have the following question. How do you generate the metapaths for a heterogeneous graph - general. In the example that you have here, since there are only two heterogeneous nodes and the feature, the meta-path scheme is obvious. In general, how do you know the meta-paths for a heterogeneous graph. From https://i.cs.hku.hk/~ckcheng/papers/www15-metapath.pdf , it looks like this is an area of research. Do you have any pointers to share. For my particular problem, I am going to reduce it to two heterogeneous nodes like your example and go with it.
Rajiv

@rajiv I’m not an expert in this area so I guess I cannot help much. In the most naive case like HAN, this can be done by raising the adjacency matrices to a power of k, i.e. if I can reach node B from node A within k steps and each step happens on a particular edge type, then A and B are considered to be on the same metapath.

Thanks, Mufei. Appreciate the help.

Hello. I ended up in the same dilemma as @rajiv. I have a graph with multiple types of nodes. All nodes have features, but I can’t find an example in the tutorials or the API teaching how to set node attributes in heterographs. Is this supported in DGL?

A little more information. A graph holds node features in the `ndata` attribute. The documentation here shows us how to assign values to `G.ndata` when all nodes in the `G` are untyped (or have a single type):

``````G = dgl.DGLGraph()
However, when working with a heterograph, you can’t use the `ndata` attribute of the graph, as mentioned in the docs for `ndata`.
Sorry for the quick replies. By studying the Relational GCN example a bit more, I realized that data for nodes of type `t` in a heterograph `G` can be stored in a dictionary `G.nodes[t].data`.