Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions dotnet/src/GraphRag/DataModel/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ public sealed record Entity : Named
/// </summary>
public IReadOnlyList<string>? TextUnitIds { get; init; }

/// <summary>
/// Gets the frequency count indicating how many times this entity was extracted.
/// </summary>
public int Frequency { get; init; }

/// <summary>
/// Gets the degree of the entity in the graph (number of relationships involving this entity).
/// </summary>
public int Degree { get; init; }

/// <summary>
/// Gets the rank of the entity.
/// </summary>
Expand Down Expand Up @@ -66,6 +76,8 @@ public static Entity FromDictionary(Dictionary<string, object?> data)
NameEmbedding = data.TryGetValue("name_embedding", out var nameEmb) ? nameEmb as IReadOnlyList<float> : null,
CommunityIds = data.TryGetValue("community_ids", out var commIds) ? commIds as IReadOnlyList<string> : null,
TextUnitIds = data.TryGetValue("text_unit_ids", out var tuIds) ? tuIds as IReadOnlyList<string> : null,
Frequency = data.TryGetValue("frequency", out var freq) && freq is int f ? f : 0,
Degree = data.TryGetValue("degree", out var deg) && deg is int d ? d : 0,
Rank = data.TryGetValue("rank", out var rank) && rank is int r ? r : 1,
Attributes = data.TryGetValue("attributes", out var attrs) ? attrs as Dictionary<string, object?> : null,
};
Expand Down
6 changes: 6 additions & 0 deletions dotnet/src/GraphRag/DataModel/Relationship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public sealed record Relationship : Identified
/// </summary>
public IReadOnlyList<string>? TextUnitIds { get; init; }

/// <summary>
/// Gets the combined degree of the source and target entities in the graph.
/// </summary>
public int CombinedDegree { get; init; }

/// <summary>
/// Gets the rank of the relationship.
/// </summary>
Expand Down Expand Up @@ -65,6 +70,7 @@ public static Relationship FromDictionary(Dictionary<string, object?> data)
Description = data.TryGetValue("description", out var desc) ? desc?.ToString() : null,
DescriptionEmbedding = data.TryGetValue("description_embedding", out var descEmb) ? descEmb as IReadOnlyList<float> : null,
TextUnitIds = data.TryGetValue("text_unit_ids", out var tuIds) ? tuIds as IReadOnlyList<string> : null,
CombinedDegree = data.TryGetValue("combined_degree", out var cd) && cd is int c ? c : 0,
Rank = data.TryGetValue("rank", out var rank) && rank is int r ? r : 1,
Attributes = data.TryGetValue("attributes", out var attrs) ? attrs as Dictionary<string, object?> : null,
};
Expand Down
Loading
Loading