@fluxgraph/knowledge
Version:
A flexible, database-agnostic knowledge graph implementation for TypeScript
64 lines (61 loc) • 2.26 kB
TypeScript
import { K as KnowledgeGraph, d as KnowledgeNode, e as KnowledgeEdge } from '../KnowledgeGraph-Bf7WVoAx.js';
import '../base-DQbXAhv3.js';
import 'drizzle-orm/sqlite-core';
import 'drizzle-orm';
/**
* Graph algorithms for analyzing and working with knowledge graphs
*/
declare class GraphAlgorithms {
private graph;
constructor(graph: KnowledgeGraph);
/**
* Calculate degree centrality for a node
* Degree centrality is the number of edges connected to a node
*/
degreeCentrality(nodeId: string): Promise<number>;
/**
* Calculate degree centrality for all nodes
*/
allDegreeCentrality(): Promise<Map<string, number>>;
/**
* Find all paths between two nodes up to a maximum length
*/
findAllPaths(fromNodeId: string, toNodeId: string, maxLength?: number): Promise<Array<{
nodes: KnowledgeNode[];
edges: KnowledgeEdge[];
length: number;
}>>;
/**
* Detect cycles in the graph
*/
detectCycles(): Promise<Array<{
nodes: string[];
edges: KnowledgeEdge[];
}>>;
/**
* Find connected components in the graph
*/
findConnectedComponents(): Promise<Array<Set<string>>>;
/**
* Calculate PageRank for all nodes
* Simplified implementation - real PageRank would need iterative computation
*/
pageRank(damping?: number, iterations?: number): Promise<Map<string, number>>;
/**
* Find nodes that form a clique (fully connected subgraph)
*/
findCliques(minSize?: number): Promise<Array<Set<string>>>;
/**
* Calculate clustering coefficient for a node
*/
clusteringCoefficient(nodeId: string): Promise<number>;
/**
* Find communities using label propagation
*/
detectCommunities(): Promise<Map<string, number>>;
}
declare function degreeCentrality(graph: KnowledgeGraph, nodeId: string): Promise<number>;
declare function findShortestPath(graph: KnowledgeGraph, fromNodeId: string, toNodeId: string): Promise<any>;
declare function detectCycles(graph: KnowledgeGraph): Promise<any>;
declare function pageRank(graph: KnowledgeGraph): Promise<Map<string, number>>;
export { GraphAlgorithms, degreeCentrality, detectCycles, findShortestPath, pageRank };