Expand description
Graph memory types for knowledge graph construction.
This module provides types for representing entities extracted from memories and relationships between them, forming a temporal knowledge graph.
§Entity Types
Entities are categorized into five types:
| Type | Description | Examples |
|---|---|---|
Person | Named individuals | “Alice Johnson”, “@username” |
Organization | Companies, teams, groups | “Anthropic”, “Backend Team” |
Concept | Abstract ideas, patterns | “REST API”, “Event Sourcing” |
Technology | Tools, frameworks, languages | “Rust”, “SQLite”, “Docker” |
File | Code files, documents | “src/main.rs”, “README.md” |
§Relationship Types
Relationships between entities include:
WorksAt- Person → OrganizationCreated- Entity → Entity (authorship)Uses- Entity → Entity (dependency)Implements- Entity → Entity (realization)PartOf- Entity → Entity (composition)RelatesTo- Entity → Entity (general association)MentionedIn- Entity → Memory (provenance)Supersedes- Entity → Entity (versioning)ConflictsWith- Entity → Entity (contradiction)
§Example
use subcog::models::graph::{Entity, EntityType, Relationship, RelationshipType, EntityId};
use subcog::models::Domain;
// Create an entity for a technology
let rust_entity = Entity::new(
EntityType::Technology,
"Rust",
Domain::for_user(),
);
// Create a relationship
let relationship = Relationship::new(
EntityId::new("person_alice"),
EntityId::new("tech_rust"),
RelationshipType::Uses,
);Structs§
- Entity
- An entity in the knowledge graph.
- Entity
Id - Unique identifier for a graph entity.
- Entity
Mention - A mention of an entity in a memory.
- Entity
Query - Query parameters for searching entities.
- Relationship
- A relationship between two entities in the knowledge graph.
- Relationship
Query - Query parameters for traversing relationships.
- Traversal
Result - Result of a graph traversal operation.
Enums§
- Entity
Type - Type of entity in the knowledge graph.
- Relationship
Type - Type of relationship between entities.
Functions§
- rand_
simple 🔒 - Simple pseudo-random number generator for ID generation. Uses thread-local state with system time seeding.