Create communities

Partitions the edge graph into sets of entities more densely connected to each other than to the rest.

POST /v1/graph/communities

Addresshttps://api.hanzo.ai/v1/graph/communities
MethodPOST
OperationgraphCommunities
AuthAuthorization: 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).

FieldInTypeRequiredDescription
as_knownbodystring—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_ofbodystring—AsOf partitions the graph as it stood at an instant of the world, RFC 3339: the edges that held then.
levelbodyinteger (int64)—Level is how fine a partition to answer with.
relationbodystring—Relation narrows the graph to one edge relation, by its key.

Response

StatusBodyMeaning
200graph.graphCommunitiesOutok
defaultproblem-detailsrefused

200 body — 14 fields.

FieldInTypeAlwaysDescription
as_knownbodystring—AsKnown is the knowledge instant it was taken at, RFC 3339, the same way.
as_ofbodystring—AsOf is the instant the graph was read at, RFC 3339: the one asked for, or the server's clock when none was.
boundbodyinteger (int64)—Bound is the most members listed in one answer.
ceilingbodyinteger (int64)—Ceiling is the most edge assertions one partition reads — every row, so an edge three sources asserted counts three times.
communitiesbodygraph.graphCommunity[]—Communities are the communities, largest first.
communities[].idbodyinteger (int64)—ID numbers the community by size, largest first, then by its lowest key.
communities[].membersbodystring[]—Members are the entities in it, in key order.
communities[].sizebodyinteger (int64)—Size is how many entities belong to it, whether or not all are listed.
edgesbodyinteger (int64)—Edges is how many distinct undirected edges were partitioned.
entitiesbodyinteger (int64)—Entities is how many entities the edge graph holds.
levelbodyinteger (int64)—Level is the level answered.
levelsbodyinteger (int64)—Levels is how many levels detection found.
modularitybodynumber (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.
truncatedbodyboolean—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 communities
import { 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();
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>"
     }'

Tool graph, op graphCommunities — POST the JSON-RPC envelope to https://api.hanzo.ai/v1/mcp.

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "graph",
         "arguments": {
           "op": "graphCommunities",
           "input": {
             "as_known": "<as_known>",
             "as_of": "<as_of>"
           }
         }
       }
     }'

Graph API · All Hanzo APIs · Interactive reference

Was this page useful?