import { Graph } from '../../../algorithms/graph/graph'; import { Edge, Node } from '../../../algorithms/types/graph'; /** * Generic node type for loaded graphs */ export interface LoadedNode extends Node { id: string; type: string; label?: string; attributes?: Record; } /** * Generic edge type for loaded graphs */ export interface LoadedEdge extends Edge { id: string; type: string; source: string; target: string; weight?: number; relation?: string; } /** * Configuration for edge list loading */ export interface EdgeListConfig { /** Delimiter between fields (default: whitespace) */ delimiter?: string | RegExp; /** Whether graph is directed (default: false) */ directed?: boolean; /** Whether to skip lines starting with # (default: true) */ skipComments?: boolean; /** Number of header lines to skip (default: 0) */ headerLines?: number; /** Default node type (default: 'Node') */ nodeType?: string; /** Column index for source node (default: 0) */ sourceColumn?: number; /** Column index for target node (default: 1) */ targetColumn?: number; /** Column index for edge weight (default: undefined = no weight) */ weightColumn?: number; } /** * Configuration for triple/knowledge graph loading */ export interface TripleConfig { /** Delimiter between fields (default: tab) */ delimiter?: string | RegExp; /** Whether to skip lines starting with # (default: true) */ skipComments?: boolean; /** Number of header lines to skip (default: 0) */ headerLines?: number; /** Column index for head entity (default: 0) */ headColumn?: number; /** Column index for relation (default: 1) */ relationColumn?: number; /** Column index for tail entity (default: 2) */ tailColumn?: number; } /** * Result of graph loading operation */ export interface LoadResult { graph: Graph; nodeCount: number; edgeCount: number; nodeTypes: Set; edgeTypes: Set; warnings: string[]; } /** * Load a graph from edge list format * * Edge list format: one edge per line * - Simple: "node1 node2" * - Weighted: "node1 node2 weight" * * @param content - File content as string * @param config - Loading configuration * @returns Loaded graph with metadata */ export declare const loadEdgeList: (content: string, config?: EdgeListConfig) => LoadResult; /** * Load a knowledge graph from triple format * * Triple format: one triple per line * - Standard: "head\trelation\ttail" * * Creates a heterogeneous graph where: * - Nodes are entities (head/tail) * - Edges have relation types * * @param content - File content as string * @param config - Loading configuration * @returns Loaded graph with metadata */ export declare const loadTriples: (content: string, config?: TripleConfig) => LoadResult; /** * Load a graph from file content with auto-detection * * Attempts to detect format based on content structure: * - 3 columns with relation-like middle field → triples * - 2-3 columns with numeric third field → weighted edge list * - 2 columns → edge list * * @param content - File content as string * @param hint - Optional format hint ('edge-list' | 'triples') * @returns Loaded graph with metadata */ export declare const loadGraph: (content: string, hint?: "edge-list" | "triples" | "weighted-edge-list") => LoadResult; /** * Load graph from a URL (for downloading benchmark datasets) * * @param url - URL to fetch graph data from * @param hint - Optional format hint * @returns Promise resolving to loaded graph with metadata */ export declare const loadGraphFromUrl: (url: string, hint?: "edge-list" | "triples" | "weighted-edge-list") => Promise; /** * Load graph from GraphJson format (produced by GML/JSON parsers). * * GraphJson format uses { nodes: [{id, ...}], edges: [{source, target, ...}] } * * @param json - Graph in GraphJson format * @param json.nodes * @param json.edges * @param json.meta * @param json.meta.directed * @param directed - Whether graph is directed (default: false) * @returns Loaded graph with metadata */ export declare const loadFromGraphJson: (json: { nodes: Array<{ id: string; }>; edges: Array<{ source: string; target: string; value?: number; weight?: number; }>; meta?: { directed?: boolean; }; }, directed?: boolean) => LoadResult; /** * Detect if a string contains GML format content. * * @param content - Content to check * @returns True if content appears to be GML format */ export declare const isGmlContent: (content: string) => boolean; /** * Load a graph from GML format content. * * Uses the GML parser to convert GML to GraphJson, then to our internal format. * * @param content - GML file content as string * @param directed - Whether graph is directed (default: false, will be detected from GML if present) * @returns Loaded graph with metadata */ export declare const loadGml: (content: string, directed?: boolean) => Promise; //# sourceMappingURL=edge-list-loader.d.ts.map