GraphEdge<T>

Models & Types · AiDotNet.RetrievalAugmentedGeneration.Graph

Represents a directed edge (relationship) between two nodes in a knowledge graph.

For Beginners

Think of an edge as a relationship or connection between two people.

In a social network:

  • “Alice WORKS_FOR Microsoft” (Alice is the source, Microsoft is the target)
  • “Bob LIVES_IN Seattle” (Bob is the source, Seattle is the target)
  • “Charlie KNOWS David” (Charlie knows David, but maybe David doesn’t know Charlie - it’s directional!)

In a knowledge graph:

  • Source: The entity the relationship starts from
  • Target: The entity the relationship points to
  • Type: The kind of relationship (WORKS_FOR, LIVES_IN, KNOWS)
  • Properties: Extra info (since: “2020”, strength: 0.9)
  • Weight: How important or strong this relationship is (0.0 to 1.0)

For example: Source: “Albert Einstein” (PERSON) Target: “Princeton University” (ORGANIZATION) Type: “WORKED_AT” Properties: { “from”: “1933”, “to”: “1955” } Weight: 0.95 (very strong relationship)

How It Works

A graph edge represents a relationship between two entities, such as “works_for”, “located_in”, or “friend_of”. Edges are directed (from source to target) and can have properties to store additional relationship metadata.

Constructors

Constructor Summary
GraphEdge(string sourceId, string targetId, string relationType, double weight) Initializes a new instance of the GraphEdge class.

Properties

Property Summary
DateTime CreatedAt { get; set; } Timestamp when this edge was created.
DateTime? ValidFrom { get; set; } Start of the temporal validity window for this relationship.
DateTime? ValidUntil { get; set; } End of the temporal validity window for this relationship.
Dictionary<string, object> Properties { get; set; } Additional properties and metadata for this relationship.
double Weight { get; set; } Weight or strength of this relationship (0.0 to 1.0).
string Id { get; set; } Unique identifier for this edge.
string RelationType { get; set; } The relationship type (e.g., WORKS_FOR, LOCATED_IN, FRIEND_OF).
string SourceId { get; set; } The source node ID (where the relationship starts).
string TargetId { get; set; } The target node ID (where the relationship points to).

Methods

Method Summary
TValue GetProperty(string key) Gets a property value from this edge.
bool Equals(object obj)
bool IsValidAt(DateTime timestamp) Checks whether this edge is valid at a specific point in time.
int GetHashCode()
string ToString()
void SetProperty(string key, object value) Adds or updates a property on this edge.
void SetTemporalWindow(DateTime? validFrom, DateTime? validUntil) Sets the temporal validity window for this edge with validation.