# pub.chive.graph.expandSubgraph

> Published by [chive.pub](https://lexicon.garden/identity/did:plc:7natp5xae72bddaqlkef2t4e)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:7natp5xae72bddaqlkef2t4e/pub.chive.graph.expandSubgraph)
- [Documentation](https://lexicon.garden/lexicon/did:plc:7natp5xae72bddaqlkef2t4e/pub.chive.graph.expandSubgraph/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:7natp5xae72bddaqlkef2t4e/pub.chive.graph.expandSubgraph/examples)

## Definitions

### `pub.chive.graph.expandSubgraph`

**Type**: `query`

Expand a subgraph from root URIs using breadth-first search, returning discovered nodes and edges.

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `depth` | `integer` | No | Maximum BFS depth. |
| `maxNodes` | `integer` | No | Maximum nodes to return. |
| `rootUris` | `array` | Yes | Starting node URIs for BFS expansion. |
| `edgeTypes` | `array` | No | Filter by edge relation slugs. If omitted, all types included. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `edges` | `array` | Yes |  |
| `nodes` | `array` | Yes |  |
| `truncated` | `boolean` | Yes | Whether result was capped at maxNodes. |

### `pub.chive.graph.expandSubgraph#subgraphEdge`

**Type**: `object`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `uri` | `string` | Yes |  |
| `label` | `string` | No |  |
| `weight` | `integer` | No |  |
| `sourceUri` | `string` | Yes |  |
| `targetUri` | `string` | Yes |  |
| `relationSlug` | `string` | Yes |  |

### `pub.chive.graph.expandSubgraph#subgraphNode`

**Type**: `object`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `uri` | `string` | Yes |  |
| `kind` | `string` | Yes |  |
| `label` | `string` | Yes |  |
| `subkind` | `string` | No |  |
| `metadata` | `unknown` | No |  |
| `description` | `string` | No |  |

## Raw Schema

```json
{
  "id": "pub.chive.graph.expandSubgraph",
  "defs": {
    "main": {
      "type": "query",
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "nodes",
            "edges",
            "truncated"
          ],
          "properties": {
            "edges": {
              "type": "array",
              "items": {
                "ref": "#subgraphEdge",
                "type": "ref"
              }
            },
            "nodes": {
              "type": "array",
              "items": {
                "ref": "#subgraphNode",
                "type": "ref"
              }
            },
            "truncated": {
              "type": "boolean",
              "description": "Whether result was capped at maxNodes."
            }
          }
        },
        "encoding": "application/json"
      },
      "parameters": {
        "type": "params",
        "required": [
          "rootUris"
        ],
        "properties": {
          "depth": {
            "type": "integer",
            "default": 2,
            "maximum": 5,
            "minimum": 1,
            "description": "Maximum BFS depth."
          },
          "maxNodes": {
            "type": "integer",
            "default": 100,
            "maximum": 200,
            "minimum": 1,
            "description": "Maximum nodes to return."
          },
          "rootUris": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxLength": 10,
            "description": "Starting node URIs for BFS expansion."
          },
          "edgeTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Filter by edge relation slugs. If omitted, all types included."
          }
        }
      },
      "description": "Expand a subgraph from root URIs using breadth-first search, returning discovered nodes and edges."
    },
    "subgraphEdge": {
      "type": "object",
      "required": [
        "uri",
        "sourceUri",
        "targetUri",
        "relationSlug"
      ],
      "properties": {
        "uri": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "weight": {
          "type": "integer",
          "maximum": 100,
          "minimum": 0
        },
        "sourceUri": {
          "type": "string"
        },
        "targetUri": {
          "type": "string"
        },
        "relationSlug": {
          "type": "string"
        }
      }
    },
    "subgraphNode": {
      "type": "object",
      "required": [
        "uri",
        "label",
        "kind"
      ],
      "properties": {
        "uri": {
          "type": "string"
        },
        "kind": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "subkind": {
          "type": "string"
        },
        "metadata": {
          "type": "unknown"
        },
        "description": {
          "type": "string"
        }
      }
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1,
  "revision": 1
}
```
