graphcoherence
Global coherence dynamics on networks — the official Python client for the GraphCoherence API.
graphcoherence is a thin HTTP client. All computation (coherence-index
sweeps, phase diagrams, spectral analysis, bridge / criticality ranking, Ricci
curvature, liquefaction) runs server-side on the GraphCoherence compute
engine. The client only normalizes your graph to the wire format, calls the
API (/api/gc/v1/*), and returns typed results. No numpy/scipy/networkx
compute happens locally.
Install
pip install graphcoherence
# optional extras
pip install "graphcoherence[pandas]" # .to_dataframe()
pip install "graphcoherence[networkx]" # nx.Graph input + .to_networkx()
Authentication
Get an API key (gc_...) from https://cognitive-engineering.dev/pricing.
Provide it in any of these ways (checked in this order):
- Environment variable:
export GRAPHCOHERENCE_API_KEY=gc_your_key
- Config file
~/.graphcoherence/config:[default] api_key = gc_your_key
- Explicitly in code:
import graphcoherence graphcoherence.configure(api_key="gc_your_key")
Quickstart
import graphcoherence as gc
# Analyze from an edge list (tuples or lists both work)
result = gc.analyze(edges=[(0, 1), (1, 2), (0, 2)])
print(result.coherence_index) # global Coherence Index
print(result.always_fragile_ratio)
df = result.to_dataframe() # one row per edge (needs [pandas])
# Analyze from a networkx graph (needs [networkx])
import networkx as nx
G = nx.karate_club_graph()
result = gc.analyze(graph=G)
# Live edge classification at a coupling value C (no DB write)
prev = gc.preview([(0, 1), (1, 2), (0, 2)], C=0.5)
for edge in prev.edge_results:
print(edge["edge_key"], edge["state"])
# Bridge / always-fragile analysis
br = gc.bridge(edges=[(0, 1), (1, 2), (2, 3)])
print(br.bridge_count, br.bridge_ratio)
# Rank the most critical edges (intervention targets)
crit = gc.criticality(graph=G, top_n=10)
for e in crit.edges:
print(e["rank"], e["edge_key"], e["ecs"])
# Spectral analysis
spec = gc.spectral(graph=G)
print(spec.lambda2, spec.eigenvalues[:5])
Using an explicit client
from graphcoherence import GCClient
client = GCClient(api_key="gc_your_key")
result = client.analyze(edges=[(0, 1), (1, 2), (0, 2)])
Input formats
Every graph-taking method accepts, interchangeably:
edges=[(0, 1), (1, 2)]— tuples or[[0, 1], [1, 2]]listsgraph=G— anetworkx.Graph(requiresgraphcoherence[networkx])graph_data="..."+graph_format="json"|"csv"— a pre-formatted stringedges="path/to/edges.csv"— a CSV file path, or raw CSV content string
Internally these normalize to the JSON format the API expects:
{"edges": [{"source": u, "target": v}, ...]}.
NetworkX interop
import networkx as nx
import graphcoherence as gc
G = nx.karate_club_graph()
result = gc.analyze(graph=G)
# Rebuild a graph carrying per-edge attributes (tri, state, ricci, ...)
H = result.to_networkx()
print(H[0][1]) # {'tri': ..., 'state': ..., 'ricci': ...}
Error handling
from graphcoherence import (
GCError, AuthError, RateLimitError, EdgeLimitError, InvalidInputError
)
try:
gc.analyze(edges=[(0, 1)])
except EdgeLimitError as e:
print("Graph too large for your tier:", e)
except RateLimitError as e:
print("Slow down:", e)
except AuthError as e:
print("Check your key:", e)
except InvalidInputError as e:
print("Bad input:", e)
except GCError as e:
print("Something went wrong:", e)
Links
- API docs: https://cognitive-engineering.dev/graphcoherence/app/api-docs
- Pricing / API keys: https://cognitive-engineering.dev/pricing
License
Proprietary. Copyright (c) 2026 Cognitive Engineering / David Martin Venti.
Metadata
Release files for graphcoherence 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| graphcoherence-0.1.0.tar.gz | 15.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| graphcoherence-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.4 kB
Release files / graphcoherence-0.1.0.tar.gz
| Download URL | graphcoherence-0.1.0.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7129a7dbcb7eb0be1a2961b9da72e388a3f5f3cc12bef05865d4d15a6c5a1b2a
|
|
BLAKE2b-256 checksum How to use checksums |
bd088ea0e93cc453ac62a39520a3ea5b352c7426685895006ca9f56818ea025a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / graphcoherence-0.1.0-py3-none-any.whl
| Download URL | graphcoherence-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fefc828254b696c9c78d2f99fd7fff6c04881801faa11dcad6232f0c658c950f
|
|
BLAKE2b-256 checksum How to use checksums |
e3914723885760aa502763150b06c2f66e26e586e340059add91e58380b5821a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|