# garden.engram.getMemoryGraph

> Published by [hailey.at](https://lexicon.garden/identity/did:plc:oisofpd7lj26yvgiivf3lxsi)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:oisofpd7lj26yvgiivf3lxsi/garden.engram.getMemoryGraph)
- [Documentation](https://lexicon.garden/lexicon/did:plc:oisofpd7lj26yvgiivf3lxsi/garden.engram.getMemoryGraph/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:oisofpd7lj26yvgiivf3lxsi/garden.engram.getMemoryGraph/examples)

## Definitions

### `garden.engram.getMemoryGraph`

**Type**: `query`

A space's newest memories and links between the ones that mean similar things, for drawing the space as a graph. Only memories indexed with the space's model are included. Each memory links to its nearest neighbors among the memories returned. Same authentication as garden.engram.searchMemories.

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `limit` | `integer` | No | How many of the newest memories to include. |
| `minSimilarity` | `string` | No | A number above 0 and at most 1 (default 0.4): the cosine similarity a pair needs to be linked. |
| `neighbors` | `integer` | No | How many of its most similar memories each memory links to. |
| `space` | `string` | Yes | The space URI. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `edges` | `array` | Yes |  |
| `nodes` | `array` | Yes | Newest first. |

#### Errors

- **UnknownSpace**: This service does not index the space.
- **NoModel**: The space has not declared an embedding model.

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "A space's newest memories and links between the ones that mean similar things, for drawing the space as a graph. Only memories indexed with the space's model are included. Each memory links to its nearest neighbors among the memories returned. Same authentication as garden.engram.searchMemories.",
      "errors": [
        {
          "description": "This service does not index the space.",
          "name": "UnknownSpace"
        },
        {
          "description": "The space has not declared an embedding model.",
          "name": "NoModel"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "edges": {
              "items": {
                "properties": {
                  "a": {
                    "description": "Position of one memory in nodes. Always smaller than b.",
                    "type": "integer"
                  },
                  "b": {
                    "description": "Position of the other memory in nodes.",
                    "type": "integer"
                  },
                  "similarity": {
                    "description": "Cosine similarity, times 1000.",
                    "maximum": 1000,
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "a",
                  "b",
                  "similarity"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "nodes": {
              "description": "Newest first.",
              "items": {
                "ref": "garden.engram.defs#memoryView",
                "type": "ref"
              },
              "type": "array"
            }
          },
          "required": [
            "nodes",
            "edges"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "limit": {
            "default": 200,
            "description": "How many of the newest memories to include.",
            "maximum": 500,
            "minimum": 1,
            "type": "integer"
          },
          "minSimilarity": {
            "description": "A number above 0 and at most 1 (default 0.4): the cosine similarity a pair needs to be linked.",
            "type": "string"
          },
          "neighbors": {
            "default": 3,
            "description": "How many of its most similar memories each memory links to.",
            "maximum": 8,
            "minimum": 1,
            "type": "integer"
          },
          "space": {
            "description": "The space URI.",
            "type": "string"
          }
        },
        "required": [
          "space"
        ],
        "type": "params"
      },
      "type": "query"
    }
  },
  "id": "garden.engram.getMemoryGraph",
  "lexicon": 1
}
```
