# Are there neural networks that accept graphs or trees as inputs?

As far I know, the RNN accepts a sequence as input and can produce as a sequence as output.

Are there neural networks that accept graphs or trees as inputs, so that to represent the relationships between the nodes of the graph or tree?

There are types of neural networks designed exactly for that purpose. For example, graph convolutional networks (GCN) by Thomas N. Kipf. The input to the network will be a matrix of size $$N \times F$$, where $$N$$ is the number of nodes and $$F$$ the number of features (for each node). You then can multiply the feature matrix with the adjacency matrix (each node is going to be a weighted sum of its first-degree neighbors). There are a lot of other variations, such as diffusion convolutional networks, gated graph neural networks, etc. There is a nice survey that describes most of the recent related work in the field Graph Neural Networks: A review of methods and applications by Jie Zhou et al.