import Graph from "graphology"; /** * Represents a single step in a trust path. */ export interface TrustPathStep { from: string; to: string; positiveWeight: number; negativeWeight: number; cumulativePositiveScore: number; cumulativeNegativeScore: number; cumulativeNetScore: number; } /** * Represents a complete trust path from source to target. */ export interface TrustPath { source: string; target: string; path: string[]; steps: TrustPathStep[]; totalPositiveScore: number; totalNegativeScore: number; totalNetScore: number; length: number; } /** * Options for finding trust paths. */ export interface FindTrustPathsOptions { maxPaths?: number; maxHops?: number; minFinalTrust?: number; minIntermediateTrust?: number; } /** * Represents a graph for computing transitive trust scores with separate positive and negative weights. */ export declare class TransitiveTrustGraph { graph: Graph; constructor(); /** * Adds a node to the graph. * @param node The node to add. * @throws {Error} If the node is not a non-empty string. */ addNode(node: string): void; /** * Adds an edge to the graph. * @param source The source node. * @param target The target node. * @param positiveWeight The positive weight of the edge (between 0 and 1, inclusive). * @param negativeWeight The negative weight of the edge (between 0 and 1, inclusive). * @throws {Error} If the source or target is not a non-empty string, or if the weights are not between 0 and 1 (inclusive). */ addEdge(source: string, target: string, positiveWeight: number, negativeWeight: number): void; /** * Computes the trust scores from a source node to all other nodes. * @param source The source node. * @returns A Map containing the trust scores for all nodes. * @throws {Error} If the source node is not found in the graph. */ private computeScores; /** * Computes the trust scores between a source node and specific target nodes. * @param source The source node. * @param targets An array of target nodes. If empty, computes for all nodes. * @returns An object containing the trust scores for the specified target nodes or all nodes. * @throws {Error} If the source or any target node is not found in the graph. */ computeTrustScores(source: string, targets?: string[]): { [target: string]: { positiveScore: number; negativeScore: number; netScore: number; }; }; /** * Returns all nodes in the graph. * @returns An array of all nodes. */ getNodes(): string[]; /** * Returns all edges in the graph. * @returns An array of objects representing edges. */ getEdges(): { source: string; target: string; positiveWeight: number; negativeWeight: number; }[]; /** * Finds trust paths between a source and target node. * @param source The source node. * @param target The target node. * @param options Options for finding paths. * @param options.maxPaths Maximum number of paths to return (default: 10). * @param options.maxHops Maximum path length (default: 6). * @param options.minFinalTrust Minimum trust score required at the target node (default: 0). * @param options.minIntermediateTrust Minimum trust score required at each intermediate node (default: 0). * @returns An array of trust paths sorted by net score (highest first). * @throws {Error} If the source or target node is not found in the graph. */ findTrustPaths(source: string, target: string, options?: FindTrustPathsOptions): TrustPath[]; }