Files
wehub-resource-sync c889a57b6b
Test Suites / Build CI Environment (push) Has been cancelled
Test Suites / Basic Tests (push) Has been cancelled
Test Suites / End-to-End Tests (push) Has been cancelled
Test Suites / CLI Tests (push) Has been cancelled
Test Suites / Slow End-to-End Tests (push) Has been cancelled
Test Suites / Graph Database Tests (push) Has been cancelled
Test Suites / Vector DB Tests (push) Has been cancelled
Test Suites / Temporal Graph Test (push) Has been cancelled
Test Suites / Search Test on Different DBs (push) Has been cancelled
Test Suites / Example Tests (push) Has been cancelled
Test Suites / Notebook Tests (push) Has been cancelled
Test Suites / OS and Python Tests Ubuntu (push) Has been cancelled
Test Suites / OS and Python Tests Extended (push) Has been cancelled
Test Suites / LLM Test Suite (push) Has been cancelled
Test Suites / S3 File Storage Test (push) Has been cancelled
Test Suites / Run Integration Tests (push) Has been cancelled
Test Suites / MCP Tests (push) Has been cancelled
Test Suites / Docker Compose Test (push) Has been cancelled
Test Suites / Docker CI test (push) Has been cancelled
Test Suites / Relational DB Migration Tests (push) Has been cancelled
Test Suites / Distributed Cognee Test (push) Has been cancelled
Test Suites / DB Examples Tests (push) Has been cancelled
Test Suites / Test Completion Status (push) Has been cancelled
Test Suites / Claude Code Review (push) Has been cancelled
Test Suites / basic checks (push) Has been cancelled
build | Build and Push Cognee MCP Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
build | Build and Push Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.11) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.12) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (kuzu, kuzu) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (neo4j, neo4j) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Examples (push) Has been cancelled
Weighted Edges Tests / Code Quality for Weighted Edges (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:02:24 +08:00

90 lines
2.8 KiB
Python

from typing import Any, Dict, List, Optional, Union
from pydantic import BaseModel, Field
class RelationshipModel(BaseModel):
"""
Represents a relationship between two entities in a model.
This class holds the type of the relationship and the identifiers for the source and
target entities. It includes the following public instance variables:
- type: A string indicating the type of relationship.
- source: A string representing the source entity of the relationship.
- target: A string representing the target entity of the relationship.
"""
type: str
source: str
target: str
class NodeModel(BaseModel):
"""
Represents a node in a hierarchical model structure with relationships to other nodes.
Public methods:
- __init__(self, node_id: str, name: str, default_relationship:
Optional[RelationshipModel] = None, children: List[Union[Dict[str, Any], NodeModel]] =
Field(default_factory=list))
Instance variables:
- node_id: Unique identifier for the node.
- name: Name of the node.
- default_relationship: Default relationship associated with the node, if any.
- children: List of child nodes or dictionaries representing children for this node.
"""
node_id: str
name: str
default_relationship: Optional[RelationshipModel] = None
children: List[Union[Dict[str, Any], "NodeModel"]] = Field(default_factory=list)
NodeModel.model_rebuild()
class OntologyNode(BaseModel):
"""
Represents a node in an ontology with a unique identifier, name, and description.
"""
id: str = Field(..., description="Unique identifier made from node name.")
name: str
description: str
class OntologyEdge(BaseModel):
"""
Represent an edge in an ontology, connecting a source and target with a specific
relationship type.
The class includes the following instance variables:
- id: A unique identifier for the edge.
- source_id: The identifier of the source node.
- target_id: The identifier of the target node.
- relationship_type: The type of relationship represented by this edge, defining how the
source and target are related.
"""
id: str
source_id: str
target_id: str
relationship_type: str
class GraphOntology(BaseModel):
"""
Represents a graph-based structure of ontology consisting of nodes and edges.
The GraphOntology class contains a collection of OntologyNode instances representing the
nodes of the graph and OntologyEdge instances representing the relationships between
them. Public methods include the management of nodes and edges as well as any relevant
graph operations. Instance variables include a list of nodes and a list of edges.
"""
nodes: list[OntologyNode]
edges: list[OntologyEdge]