# ml-on-structures/graph-lstm architecture

> Architecture diagram of the GitHub repository ml-on-structures/graph-lstm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ml-on-structures/graph-lstm
- Repository: https://github.com/ml-on-structures/graph-lstm

## Overview

Graph-LSTM is a small Python machine-learning library, not a graph database or end-to-end graph ingestion service. Its documented prediction workflow unfolds a target node’s neighborhood into a tree, summarizes child sequences with level-specific LSTMs, and combines the root summary with target features in a DNN. It also provides standalone DNN and LSTM implementations and JSON serialization helpers. The README documents neighborhood unfolding, but the sampled code does not show a separate graph-unfolding implementation; the wrapper operates on tree instances.

Main entry points: [`multi_level_lstm.py`](https://github.com/ml-on-structures/graph-lstm/blob/master/multi_level_lstm.py) (Multi-level LSTM), [`mlslnn.py`](https://github.com/ml-on-structures/graph-lstm/blob/master/mlslnn.py) (MLSLNN wrapper), [`json_plus.py`](https://github.com/ml-on-structures/graph-lstm/blob/master/json_plus.py) (JSON serialization), [`lstm.py`](https://github.com/ml-on-structures/graph-lstm/blob/master/lstm.py) (Sequence LSTM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Graph prediction"]
  node_tree["Unfolded tree"]
  node_mlsl["Multi-level LSTM"]
  node_wrapper["MLSLNN wrapper<br/>[mlslnn.py]"]
  node_prediction["Node prediction<br/>[mlslnn.py]"]
end

subgraph group_models["Neural models"]
  node_level_lstm["Sequence LSTM<br/>[lstm.py]"]
  node_dnn["Deep neural network<br/>[dnn.py]"]
end

subgraph group_support["Serialization support"]
  node_serialization["JSON serialization<br/>[json_plus.py]"]
end

node_user(("Prediction caller"))

node_user -->|"unfolds neighborhood"| node_tree
node_tree -->|"provides tree"| node_mlsl
node_mlsl -->|"uses per-level"| node_level_lstm
node_mlsl -->|"supplies summary"| node_wrapper
node_wrapper -->|"forwards tree"| node_mlsl
node_wrapper -->|"forwards features"| node_dnn
node_wrapper -->|"returns output"| node_prediction
node_dnn -->|"imports"| node_serialization
node_level_lstm -->|"imports"| node_serialization
node_mlsl -->|"uses storage"| node_serialization

click node_tree "https://github.com/ml-on-structures/graph-lstm/blob/master/multi_level_lstm.py"
click node_mlsl "https://github.com/ml-on-structures/graph-lstm/blob/master/multi_level_lstm.py"
click node_wrapper "https://github.com/ml-on-structures/graph-lstm/blob/master/mlslnn.py"
click node_prediction "https://github.com/ml-on-structures/graph-lstm/blob/master/mlslnn.py"
click node_level_lstm "https://github.com/ml-on-structures/graph-lstm/blob/master/lstm.py"
click node_dnn "https://github.com/ml-on-structures/graph-lstm/blob/master/dnn.py"
click node_serialization "https://github.com/ml-on-structures/graph-lstm/blob/master/json_plus.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tree,node_mlsl,node_wrapper,node_prediction toneBlue
class node_level_lstm,node_dnn toneAmber
class node_serialization toneMint
class node_user toneIndigo
```

## Components

### Graph prediction

- [Unfolded tree](https://github.com/ml-on-structures/graph-lstm/blob/master/multi_level_lstm.py): `multi_level_lstm.py`
- [Multi-level LSTM](https://github.com/ml-on-structures/graph-lstm/blob/master/multi_level_lstm.py): `multi_level_lstm.py`
- [MLSLNN wrapper](https://github.com/ml-on-structures/graph-lstm/blob/master/mlslnn.py): `mlslnn.py`
- [Node prediction](https://github.com/ml-on-structures/graph-lstm/blob/master/mlslnn.py): `mlslnn.py`

### Neural models

- [Sequence LSTM](https://github.com/ml-on-structures/graph-lstm/blob/master/lstm.py): `lstm.py`
- [Deep neural network](https://github.com/ml-on-structures/graph-lstm/blob/master/dnn.py): `dnn.py`

### Serialization support

- [JSON serialization](https://github.com/ml-on-structures/graph-lstm/blob/master/json_plus.py): `json_plus.py`

### Other components

- **Prediction caller**

## Connections

- Prediction caller → Unfolded tree: unfolds neighborhood (evidence: `README.md`)
- Unfolded tree → Multi-level LSTM: provides tree (evidence: `README.md`)
- Multi-level LSTM → Sequence LSTM: uses per-level (evidence: `multi_level_lstm.py`)
- Multi-level LSTM → MLSLNN wrapper: supplies summary (evidence: `mlslnn.py`)
- MLSLNN wrapper → Multi-level LSTM: forwards tree (evidence: `mlslnn.py`)
- MLSLNN wrapper → Deep neural network: forwards features (evidence: `mlslnn.py`)
- MLSLNN wrapper → Node prediction: returns output (evidence: `mlslnn.py`)
- Deep neural network → JSON serialization: imports (evidence: `dnn.py`)
- Sequence LSTM → JSON serialization: imports (evidence: `lstm.py`)
- Multi-level LSTM → JSON serialization: uses storage (evidence: `multi_level_lstm.py`)
