Graphs
Graphs
Graphs allow you to store and query knowledge graphs, social networks, and other graph-structured data. SeeMe.ai uses DGraph as the underlying graph database.
Graphs
Get all graphs
graphs = client.get_graphs()Create a graph
from seeme.types import Graph
my_graph = Graph(
name="Knowledge Graph",
description="A graph of entities and relationships",
kind="knowledge"
)
my_graph = client.create_graph(my_graph)| Parameter | Type | Description |
|---|---|---|
| graph | Graph | The graph object |
Graph properties:
| Property | Type | Description |
|---|---|---|
| id | str | Unique id for the graph |
| created_at | str | The creation date |
| updated_at | str | Last updated date |
| name | str | The graph name |
| description | str | The graph description |
| user_id | str | The user id of the graph creator |
| active_version_id | str | The id of the active graph version |
| kind | str | Graph type: “property”, “knowledge”, “social”, “network” |
| config | str | JSON configuration |
| schema_config | str | Node/edge type definitions |
| versions | List[GraphVersion] | List of graph versions |
| public | bool | Whether the graph is public |
Get a graph
graph = client.get_graph(my_graph.id)Update a graph
my_graph.description = "Updated knowledge graph"
client.update_graph(my_graph)Delete a graph
client.delete_graph(my_graph.id)Get graph statistics
stats = client.get_graph_stats(my_graph.id)Graph Versions
Get all graph versions
versions = client.get_graph_versions(my_graph.id)Create a graph version
from seeme.types import GraphVersion
new_version = GraphVersion(
name="v2",
description="Expanded schema",
graph_id=my_graph.id
)
new_version = client.create_graph_version(my_graph.id, new_version)GraphVersion properties:
| Property | Type | Description |
|---|---|---|
| id | str | Unique id for the version |
| name | str | The version name |
| description | str | The version description |
| graph_id | str | The parent graph id |
| version | str | Version label |
| version_number | int | Auto-incrementing version number |
| space_name | str | DGraph space name |
| graph_schema | str | Schema definition |
| node_count | int | Number of nodes |
| edge_count | int | Number of edges |
| config | str | Version configuration |
Get a graph version
version = client.get_graph_version(my_graph.id, new_version.id)Update a graph version
new_version.description = "Production schema"
client.update_graph_version(my_graph.id, new_version)Delete a graph version
client.delete_graph_version(my_graph.id, new_version.id)Set active graph version
client.set_active_graph_version(my_graph.id, new_version.id)Duplicate a graph version
Create a copy of an existing version:
duplicated = client.duplicate_graph_version(my_graph.id, new_version.id)Graph Nodes
Create a node
from seeme.types import GraphNode
node = GraphNode(
type="Person",
external_id="person_001",
properties={
"name": "John Doe",
"age": 30,
"email": "john@example.com"
}
)
result = client.create_graph_node(my_graph.id, new_version.id, node)GraphNode properties:
| Property | Type | Description |
|---|---|---|
| uid | str | DGraph internal UID |
| external_id | str | Your custom identifier |
| type | str | Node type (e.g., “Person”, “Company”) |
| properties | dict | Key-value properties |
Create multiple nodes (bulk)
nodes = [
GraphNode(type="Person", external_id="p1", properties={"name": "Alice"}),
GraphNode(type="Person", external_id="p2", properties={"name": "Bob"}),
GraphNode(type="Company", external_id="c1", properties={"name": "Acme Inc"})
]
result = client.create_graph_nodes(my_graph.id, new_version.id, nodes)Get a node
node = client.get_graph_node(my_graph.id, new_version.id, node_uid)Update a node
updated_node = GraphNode(
type="Person",
properties={"name": "John Smith", "age": 31}
)
client.update_graph_node(my_graph.id, new_version.id, node_uid, updated_node)Delete a node
client.delete_graph_node(my_graph.id, new_version.id, node_uid)Query nodes
params = {
"type": "Person",
"limit": 100
}
nodes = client.query_graph_nodes(my_graph.id, new_version.id, params)Graph Edges
Create an edge
from seeme.types import GraphEdge
edge = GraphEdge(
source_uid=person_node_uid,
target_uid=company_node_uid,
type="WORKS_AT",
properties={
"since": "2020-01-01",
"role": "Engineer"
}
)
result = client.create_graph_edge(my_graph.id, new_version.id, edge)GraphEdge properties:
| Property | Type | Description |
|---|---|---|
| uid | str | DGraph internal UID |
| source_uid | str | Source node UID |
| target_uid | str | Target node UID |
| type | str | Edge type (e.g., “WORKS_AT”, “KNOWS”) |
| properties | dict | Key-value properties |
Create multiple edges (bulk)
edges = [
GraphEdge(source_uid=p1_uid, target_uid=p2_uid, type="KNOWS"),
GraphEdge(source_uid=p1_uid, target_uid=c1_uid, type="WORKS_AT"),
]
result = client.create_graph_edges(my_graph.id, new_version.id, edges)Delete an edge
client.delete_graph_edge(my_graph.id, new_version.id)Graph Queries
Execute DQL (DGraph Query Language) queries on your graph:
query = """
{
people(func: type(Person)) {
uid
name
age
works_at {
name
}
}
}
"""
result = client.execute_graph_query(my_graph.id, new_version.id, query)| Parameter | Type | Description |
|---|---|---|
| graph_id | str | The graph id |
| version_id | str | The graph version id |
| query | str | DQL query string |
Example: Find connected nodes
query = """
{
connections(func: uid("0x1")) {
uid
name
knows {
uid
name
}
}
}
"""
result = client.execute_graph_query(my_graph.id, new_version.id, query)Example: Filter by property
query = """
{
engineers(func: type(Person)) @filter(eq(role, "Engineer")) {
uid
name
email
}
}
"""
result = client.execute_graph_query(my_graph.id, new_version.id, query)