Skip to main content

Module graph

Module graph 

Source
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:

TypeDescriptionExamples
PersonNamed individuals“Alice Johnson”, “@username”
OrganizationCompanies, teams, groups“Anthropic”, “Backend Team”
ConceptAbstract ideas, patterns“REST API”, “Event Sourcing”
TechnologyTools, frameworks, languages“Rust”, “SQLite”, “Docker”
FileCode files, documents“src/main.rs”, “README.md”

§Relationship Types

Relationships between entities include:

  • WorksAt - Person → Organization
  • Created - 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.
EntityId
Unique identifier for a graph entity.
EntityMention
A mention of an entity in a memory.
EntityQuery
Query parameters for searching entities.
Relationship
A relationship between two entities in the knowledge graph.
RelationshipQuery
Query parameters for traversing relationships.
TraversalResult
Result of a graph traversal operation.

Enums§

EntityType
Type of entity in the knowledge graph.
RelationshipType
Type of relationship between entities.

Functions§

rand_simple 🔒
Simple pseudo-random number generator for ID generation. Uses thread-local state with system time seeding.