UNPKG

@graphty/algorithms

Version:

Graph algorithms library for browser environments implemented in TypeScript

63 lines 1.99 kB
/** * K-Core Decomposition Algorithm * * Finds the k-core subgraph where each node has at least k neighbors * within the subgraph. Used for identifying cohesive groups and * understanding graph structure. */ export interface KCoreResult<T> { cores: Map<number, Set<T>>; coreness: Map<T, number>; maxCore: number; } /** * K-Core decomposition algorithm * Finds all k-cores in the graph and assigns coreness values to nodes * * @param graph - Undirected graph as adjacency list * @returns K-core decomposition results * * Time Complexity: O(V + E) * Space Complexity: O(V) */ export declare function kCoreDecomposition<T>(graph: Map<T, Set<T>>): KCoreResult<T>; /** * Extract the k-core subgraph * Returns nodes that belong to k-core or higher * * @param graph - Undirected graph * @param k - Core number * @returns Set of nodes in k-core or higher */ export declare function getKCore<T>(graph: Map<T, Set<T>>, k: number): Set<T>; /** * Get the induced subgraph for k-core * Returns the actual subgraph containing only k-core nodes * * @param graph - Original graph * @param k - Core number * @returns K-core subgraph */ export declare function getKCoreSubgraph<T>(graph: Map<T, Set<T>>, k: number): Map<T, Set<T>>; /** * Degeneracy ordering of the graph * Orders nodes by their coreness values * * @param graph - Undirected graph * @returns Array of nodes ordered by degeneracy */ export declare function degeneracyOrdering<T>(graph: Map<T, Set<T>>): T[]; /** * Find k-truss subgraph (triangular k-cores) * Each edge must be part of at least k-2 triangles * * @param graph - Undirected graph * @param k - Truss number (k >= 2) * @returns Edges in k-truss */ export declare function kTruss<T>(graph: Map<T, Set<T>>, k: number): Set<string>; /** * Convert directed graph to undirected for k-core analysis */ export declare function toUndirected<T>(directedGraph: Map<T, Map<T, number>>): Map<T, Set<T>>; //# sourceMappingURL=k-core.d.ts.map