import { BaseImplicitGraph, NodeID } from './BaseImplicitGraph'; import { ArkModule, ModuleID } from '../model/ArkModule'; import { Canonicalizer } from '../../utils/Canonicalizer'; /** * Dependency type enum, indicating the source of a dependency edge. * Used during SCC post-processing to remove edges by priority when splitting oversized module groups. * * Priority (removal priority; higher value = removed first): * - DEV_DEPENDENCIES (devDependencies): only needed during development, removed first * - DYNAMIC (dynamicDependencies): runtime dynamic loading, removed next * - DEPENDENCIES (dependencies): core dependency, removed last */ export declare enum DependencyType { DEPENDENCIES = 0, DYNAMIC = 1, DEV_DEPENDENCIES = 2 } /** * Module dependency graph, based on BaseImplicitGraph. * The node type is ArkModule, and edges represent dependency relationships between modules. * * Differences from DependsGraph (BaseExplicitGraph): * - No BaseNode/BaseEdge objects needed; the node is the ArkModule itself * - Edge information is implicitly stored via succMap/predMap (Map) * - Works with Canonicalizer to provide bidirectional ArkModule <-> NodeID mapping * * SCCDetection has been generalized to accept any graph implementing GraphTraits, * i.e. one providing nodesItor(), getNode(id), getNodeID(node), succ(id) methods. * ModuleDepGraph satisfies these methods by inheriting from BaseImplicitGraph, * without requiring nodes to have BaseNode methods like getID() or getOutgoingEdges(). */ export declare class ModuleDepGraph extends BaseImplicitGraph { /** * Module Canonicalizer for bidirectional ArkModule <-> ModuleID(NodeID) mapping. * Shares the same instance with the owning Scene's moduleCanonicalizer. */ private moduleCanonicalizer; /** * Edge type map, key is `${srcId}->${dstId}`, value is the dependency type. * Used during SCC post-processing to remove edges by dependency type priority. */ private edgeTypeMap; /** * Topological order of nodes after SCC refinement, populated by refineSCCGroups. * Depended-on modules appear before their dependents. */ private topoOrder; /** * SCC groups: NodeID -> all NodeIDs in the same SCC group. * Populated by refineSCCGroups and retained for later queries. */ private sccGroups; /** * SCC post-processing threshold: the maximum allowed number of modules in a group; SCCs * exceeding this size are split. Default 3; set to Number.MAX_SAFE_INTEGER to disable. */ private maxSCCGroupSize; constructor(moduleCanonicalizer: Canonicalizer); getGraphName(): string; /** * Add a module node to the graph. * The node's NodeID directly uses the ModuleID assigned by the Canonicalizer. */ addModule(module: ArkModule): void; /** * Add a dependency edge: src depends on dst (src -> dst). * succMap stores successors (dependency targets), predMap stores predecessors (dependents). * @param type Dependency type, used for edge removal priority during SCC post-processing. * When the same edge is added twice, the type with the lower removal priority is kept (i.e. the more core dependency). */ addDependencyEdge(srcId: NodeID, dstId: NodeID, type?: DependencyType): void; /** * Remove a dependency edge. */ removeDependencyEdge(srcId: NodeID, dstId: NodeID): void; /** * Remove a node ID from an adjacency list entry. */ private removeFromAdjacencyList; /** * Get the dependency type of a specific edge. * @returns The dependency type, or undefined if the edge does not exist. */ getEdgeType(srcId: NodeID, dstId: NodeID): DependencyType | undefined; /** * Get all successor (dependency target) module IDs of the specified module. */ getSuccModuleIds(moduleId: ModuleID): ModuleID[]; /** * Get all predecessor (dependent) module IDs of the specified module. */ getPredModuleIds(moduleId: ModuleID): ModuleID[]; /** * Check whether a dependency edge exists between two modules. */ hasDependencyEdge(srcId: NodeID, dstId: NodeID): boolean; /** * Get the total number of edges in the graph. */ getEdgeCount(): number; /** * Get the topological order produced by the last refineSCCGroups call. * Depended-on modules appear before their dependents. */ getTopoOrder(): NodeID[]; /** * Get the SCC groups map (NodeID -> all NodeIDs in the same SCC group) produced by the last * refineSCCGroups call. */ getSCCGroups(): Map; /** * Set the SCC post-processing threshold. SCCs larger than this size are split. * Set to Number.MAX_SAFE_INTEGER to disable post-processing. */ setMaxSCCGroupSize(maxGroupSize: number): void; /** Current SCC post-processing threshold. */ getMaxSCCGroupSize(): number; /** * Detect strong bridges in the SCC subgraph. * A strong bridge is a directed edge whose removal increases the number of SCCs. * For each edge u->v, check if removing it causes u and v to no longer be * mutually reachable. If either u cannot reach v or v cannot reach u without * the edge, then u->v is a strong bridge. * @param members Node IDs in the large SCC * @returns Array of strong bridge edges with their dependency types */ findStrongBridges(members: NodeID[]): Array<{ src: NodeID; dst: NodeID; type: DependencyType; }>; /** * Check if 'from' can reach 'to' in the subgraph, excluding edge excludedSrc->excludedDst. * Uses DFS over successor edges within the member set. */ private canReachWithoutEdge; /** * Build a temporary subgraph excluding specified edges, for SCC post-processing. * Does not modify the original graph. Edge type labels are preserved from the original graph. * @param sccMembers Node IDs in the SCC subgraph * @param excludedEdges Set of edge keys ("srcId->dstId") to exclude * @returns A new ModuleDepGraph containing only the SCC subgraph without excluded edges */ buildTempGraphWithoutEdges(sccMembers: NodeID[], excludedEdges: Set): ModuleDepGraph; /** * Recompute SCC on a temporary subgraph excluding specified edges, returning group results. * @param members Node IDs in the SCC * @param excludedEdges Set of edge keys to exclude from the temporary subgraph * @returns Array of SCC groups, each group is an array of NodeIDs */ recomputeSCC(members: NodeID[], excludedEdges: Set): NodeID[][]; /** * Split a single large SCC using strong bridge detection first, * then fall back to dependency type priority for remaining edges. * Does not modify the original graph. * @param members Node IDs in the large SCC * @param maxGroupSize Maximum allowed group size after splitting * @returns Array of split groups, each group is an array of NodeIDs */ splitLargeSCC(members: NodeID[], maxGroupSize: number): NodeID[][]; /** * Refine SCC groups: split groups exceeding maxGroupSize using strong bridge * detection and dependency type priority fallback. * Stores the resulting groups in {@link sccGroups} and returns the same map. * Also populates the topoOrder field with nodes in dependency order (depended-on first). * @param maxGroupSize Maximum allowed group size; Number.MAX_SAFE_INTEGER disables post-processing * @returns Map from each member NodeID to its group members array */ refineSCCGroups(maxGroupSize: number): Map; /** * Add members to topoOrder and sccGroups, skipping already-added members. */ private addToTopoAndGroups; } //# sourceMappingURL=ModuleDepGraph.d.ts.map