UNPKG

@graphty/algorithms

Version:

Graph algorithms library for browser environments implemented in TypeScript

32 lines 1.26 kB
import type { Graph } from "../../core/graph.js"; import type { NodeId } from "../../types/index.js"; /** * Graph Isomorphism (VF2) algorithm implementation * * Determines if two graphs are isomorphic (structurally identical). * Two graphs are isomorphic if there exists a bijection between their vertices * that preserves adjacency. * * Based on the VF2 algorithm by Cordella et al. (2004) * * Time complexity: O(n! × n) worst case, but typically much faster * Space complexity: O(n) */ export interface IsomorphismResult { isIsomorphic: boolean; mapping?: Map<NodeId, NodeId>; } export interface IsomorphismOptions { nodeMatch?: (node1: NodeId, node2: NodeId, g1: Graph, g2: Graph) => boolean; edgeMatch?: (edge1: [NodeId, NodeId], edge2: [NodeId, NodeId], g1: Graph, g2: Graph) => boolean; findAllMappings?: boolean; } /** * Check if two graphs are isomorphic using VF2 algorithm */ export declare function isGraphIsomorphic(graph1: Graph, graph2: Graph, options?: IsomorphismOptions): IsomorphismResult; /** * Find all isomorphisms between two graphs */ export declare function findAllIsomorphisms(graph1: Graph, graph2: Graph, options?: IsomorphismOptions): Map<NodeId, NodeId>[]; //# sourceMappingURL=isomorphism.d.ts.map