Create communities
Partitions the edge graph into sets of entities more densely connected to each other than to the rest.
POST /v1/graph/communities
| Address | https://api.hanzo.ai/v1/graph/communities |
| Method | POST |
| Operation | graphCommunities |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Partitions the edge graph into sets of entities more densely connected to each other than to the rest.
The graph is the one a walk reads, direction dropped, and the partition is deterministic: the same graph at the same point numbers the same communities.
Time: as_of and as_known place the graph that is partitioned; either absent is now.
Request
4 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
as_known | body | string | — | AsKnown is how much this plane had heard, RFC 3339: the answer as it would have been given then, which is what makes a past answer reproducible. |
as_of | body | string | — | AsOf partitions the graph as it stood at an instant of the world, RFC 3339: the edges that held then. |
level | body | integer (int64) | — | Level is how fine a partition to answer with. |
relation | body | string | — | Relation narrows the graph to one edge relation, by its key. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | graph.graphCommunitiesOut | ok |
default | problem-details | refused |
200 body — 14 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
as_known | body | string | — | AsKnown is the knowledge instant it was taken at, RFC 3339, the same way. |
as_of | body | string | — | AsOf is the instant the graph was read at, RFC 3339: the one asked for, or the server's clock when none was. |
bound | body | integer (int64) | — | Bound is the most members listed in one answer. |
ceiling | body | integer (int64) | — | Ceiling is the most edge assertions one partition reads — every row, so an edge three sources asserted counts three times. |
communities | body | graph.graphCommunity[] | — | Communities are the communities, largest first. |
communities[].id | body | integer (int64) | — | ID numbers the community by size, largest first, then by its lowest key. |
communities[].members | body | string[] | — | Members are the entities in it, in key order. |
communities[].size | body | integer (int64) | — | Size is how many entities belong to it, whether or not all are listed. |
edges | body | integer (int64) | — | Edges is how many distinct undirected edges were partitioned. |
entities | body | integer (int64) | — | Entities is how many entities the edge graph holds. |
level | body | integer (int64) | — | Level is the level answered. |
levels | body | integer (int64) | — | Levels is how many levels detection found. |
modularity | body | number (double) | — | Modularity is Newman's Q of this level's partition, from -0.5 to 1: the share of edge weight inside communities, less what chance would put there. |
truncated | body | boolean | — | Truncated says the member lists stop at Bound entities in all, filled in community order. |
Failure carries the platform error shape — see Errors.
Examples
hanzo graph communitiesimport { Configuration, GraphApi } from 'hanzoai';
const api = new GraphApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.graphCommunities({ as_known: "<as_known>", as_of: "<as_of>" });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import GraphApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = GraphApi(client).graph_communities(as_known="<as_known>", as_of="<as_of>")cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)
resp, _, err := client.GraphAPI.GraphCommunities(context.Background()).Execute()
if err != nil {
return err
}use hanzo_client::apis::{configuration::Configuration, graph_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = graph_api::graph_communities(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.GraphApi;
ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));
var result = new GraphApi(client).graphCommunities();The method above is the one at the current release of the document. [email protected] (npm) and [email protected] (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. SDKs →
curl -X POST https://api.hanzo.ai/v1/graph/communities \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"as_known": "<as_known>",
"as_of": "<as_of>"
}'MCP declares no tool for graph — tools/list on https://api.hanzo.ai/v1/mcp names the products it does reach. Use HTTP or an SDK.
How is this guide?