GraphAnalytics

Helpers & Utilities · AiDotNet.RetrievalAugmentedGeneration.Graph

Provides graph analytics algorithms for analyzing knowledge graphs.

For Beginners

Graph analytics help you understand your graph.

Think of a social network:

  • PageRank: Who are the most influential people?
  • Degree Centrality: Who has the most connections?
  • Closeness Centrality: Who can reach everyone quickly?
  • Betweenness Centrality: Who connects different groups?

These algorithms answer “who’s important?” and “how are things connected?”

How It Works

This class implements common graph algorithms used to analyze the structure and importance of nodes and edges in a knowledge graph.

Methods

Method Summary
Dictionary<string, double> CalculateBetweennessCentrality(KnowledgeGraph<T> graph, bool normalized) Calculates betweenness centrality for all nodes in the graph.
Dictionary<string, double> CalculateClosenessCentrality(KnowledgeGraph<T> graph) Calculates closeness centrality for all nodes in the graph.
Dictionary<string, double> CalculateClusteringCoefficient(KnowledgeGraph<T> graph) Calculates the clustering coefficient for each node.
Dictionary<string, double> CalculateDegreeCentrality(KnowledgeGraph<T> graph, bool normalized) Calculates degree centrality for all nodes in the graph.
Dictionary<string, double> CalculatePageRank(KnowledgeGraph<T> graph, double dampingFactor, int maxIterations, double convergenceThreshold) Calculates PageRank scores for all nodes in the graph.
Dictionary<string, int> DetectCommunitiesLabelPropagation(KnowledgeGraph<T> graph, int maxIterations) Detects communities using Label Propagation algorithm.
List<HashSet<string>> FindConnectedComponents(KnowledgeGraph<T> graph) Finds all connected components in the graph.
List<ValueTuple<string, double>> GetTopKNodes(Dictionary<string, double> centrality, int k) Identifies the top-k most central nodes based on a centrality measure.
double CalculateAverageClusteringCoefficient(KnowledgeGraph<T> graph) Calculates the average clustering coefficient for the entire graph.