# pub.chive.graph.getCommunities

> 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.getCommunities)
- [Documentation](https://lexicon.garden/lexicon/did:plc:7natp5xae72bddaqlkef2t4e/pub.chive.graph.getCommunities/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:7natp5xae72bddaqlkef2t4e/pub.chive.graph.getCommunities/examples)

## Definitions

### `pub.chive.graph.getCommunities`

**Type**: `query`

Detect communities in the knowledge graph using graph clustering algorithms

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `limit` | `integer` | No | Maximum communities to return |
| `minSize` | `integer` | No | Minimum community size |
| `algorithm` | `string` | No | Community detection algorithm |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `total` | `integer` | Yes | Total communities found |
| `algorithm` | `string` | Yes | Algorithm used |
| `communities` | `array` | Yes | Detected communities |
| `generatedAt` | `string` (datetime) | Yes | Timestamp when generated |

### `pub.chive.graph.getCommunities#communityResult`

**Type**: `object`

Community detection result

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `size` | `integer` | Yes | Number of members |
| `members` | `array` | Yes | Member URIs |
| `communityId` | `integer` | Yes | Community identifier |
| `representativeMembers` | `array` | No | Representative members with labels |

### `pub.chive.graph.getCommunities#representativeMember`

**Type**: `object`

Representative community member

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `uri` | `string` | Yes | Member AT-URI |
| `label` | `string` | Yes | Member label |

## Raw Schema

```json
{
  "id": "pub.chive.graph.getCommunities",
  "defs": {
    "main": {
      "type": "query",
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "communities",
            "algorithm",
            "total",
            "generatedAt"
          ],
          "properties": {
            "total": {
              "type": "integer",
              "description": "Total communities found"
            },
            "algorithm": {
              "type": "string",
              "description": "Algorithm used",
              "knownValues": [
                "louvain",
                "label-propagation"
              ]
            },
            "communities": {
              "type": "array",
              "items": {
                "ref": "#communityResult",
                "type": "ref"
              },
              "description": "Detected communities"
            },
            "generatedAt": {
              "type": "string",
              "format": "datetime",
              "description": "Timestamp when generated"
            }
          }
        },
        "encoding": "application/json"
      },
      "parameters": {
        "type": "params",
        "properties": {
          "limit": {
            "type": "integer",
            "default": 20,
            "maximum": 100,
            "minimum": 1,
            "description": "Maximum communities to return"
          },
          "minSize": {
            "type": "integer",
            "default": 2,
            "minimum": 1,
            "description": "Minimum community size"
          },
          "algorithm": {
            "type": "string",
            "default": "louvain",
            "description": "Community detection algorithm",
            "knownValues": [
              "louvain",
              "label-propagation"
            ]
          }
        }
      },
      "description": "Detect communities in the knowledge graph using graph clustering algorithms"
    },
    "communityResult": {
      "type": "object",
      "required": [
        "communityId",
        "members",
        "size"
      ],
      "properties": {
        "size": {
          "type": "integer",
          "description": "Number of members"
        },
        "members": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Member URIs"
        },
        "communityId": {
          "type": "integer",
          "description": "Community identifier"
        },
        "representativeMembers": {
          "type": "array",
          "items": {
            "ref": "#representativeMember",
            "type": "ref"
          },
          "description": "Representative members with labels"
        }
      },
      "description": "Community detection result"
    },
    "representativeMember": {
      "type": "object",
      "required": [
        "uri",
        "label"
      ],
      "properties": {
        "uri": {
          "type": "string",
          "description": "Member AT-URI"
        },
        "label": {
          "type": "string",
          "description": "Member label"
        }
      },
      "description": "Representative community member"
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1,
  "revision": 1
}
```
