import { Graph } from '../graph/graph'; import { ExtractionError } from '../types/errors'; import { Edge, Node } from '../types/graph'; import { Result } from '../types/result'; import { KTrussOptions } from './validators'; /** * Computes triangle support for all edges in the graph. * * Triangle support = number of triangles an edge participates in. * For undirected graph: edge (u,v) is in triangle with node w if edges (u,w) and (v,w) exist. * For directed graph: treat all edges as undirected for triangle counting. * * Algorithm: * 1. For each edge (u,v), find common neighbors of u and v * 2. Each common neighbor w forms a triangle (u,v,w) * 3. Count triangles = |neighbors(u) ∩ neighbors(v)| * @param graph - Input graph (directed or undirected) * @returns Result containing map of edge ID to triangle count * @example * ```typescript * const result = computeTriangleSupport(graph); * if (result.ok) { * const support = result.value; * console.log(`Edge e1 participates in ${support.get('e1')} triangles`); * } * ``` */ export declare const computeTriangleSupport: (graph: Graph) => Result, ExtractionError>; /** * Extracts k-truss subgraph from the input graph. * * K-truss: maximal subgraph where every edge participates in at least (k-2) triangles. * - 2-truss = entire graph (k-2=0, all edges included) * - 3-truss = edges in at least 1 triangle * - 4-truss = edges in at least 2 triangles * * Algorithm (iterative edge removal): * 1. Compute initial triangle support for all edges * 2. Create a working copy of the graph * 3. While edges with support < (k-2) exist: * a. Remove edge with insufficient support * b. Update triangle support for affected edges * c. Mark affected edges for recheck * 4. Return remaining subgraph * @param graph - Input graph (directed or undirected) * @param options - K-truss options (k value, hierarchy flag) * @returns Result containing k-truss subgraph or error * @example * ```typescript * // Extract 3-truss (edges in at least 1 triangle) * const result = extractKTruss(graph, { k: 3 }); * if (result.ok) { * const truss = result.value; * console.log(`3-truss has ${truss.getNodeCount()} nodes`); * } * ``` */ export declare const extractKTruss: (graph: Graph, options: KTrussOptions) => Result, ExtractionError>; //# sourceMappingURL=truss.d.ts.map