@graphty/algorithms
Version:
Graph algorithms library for browser environments implemented in TypeScript
79 lines • 1.97 kB
TypeScript
import { Graph } from "../core/graph.js";
import type { NodeId } from "../types/index.js";
/**
* Convert Graph class to Map representation
* Used by community detection and flow algorithms
*/
export declare function graphToMap(graph: Graph): Map<string, Map<string, number>>;
/**
* Convert Map representation to Graph class
*/
export declare function mapToGraph(map: Map<string, Map<string, number>>, isDirected?: boolean): Graph;
/**
* Adapter for using Graph algorithms with Map representation
* Implements a subset of Graph interface methods needed by algorithms
*/
export declare class GraphAdapter {
private map;
readonly isDirected: boolean;
constructor(map: Map<string, Map<string, number>>, isDirected?: boolean);
/**
* Get all nodes
*/
nodes(): {
id: NodeId;
}[];
/**
* Get node count
*/
get nodeCount(): number;
/**
* Check if node exists
*/
hasNode(nodeId: NodeId): boolean;
/**
* Get neighbors of a node
*/
neighbors(nodeId: NodeId): NodeId[];
/**
* Get edge between two nodes
*/
getEdge(source: NodeId, target: NodeId): {
source: NodeId;
target: NodeId;
weight?: number;
} | null;
/**
* Check if edge exists
*/
hasEdge(source: NodeId, target: NodeId): boolean;
/**
* Get all edges
*/
edges(): {
source: NodeId;
target: NodeId;
weight?: number;
}[];
/**
* Get edge count
*/
get edgeCount(): number;
/**
* Get node degree
*/
degree(nodeId: NodeId): number;
/**
* Get in-degree (for directed graphs)
*/
inDegree(nodeId: NodeId): number;
/**
* Get out-degree (for directed graphs)
*/
outDegree(nodeId: NodeId): number;
/**
* Get underlying map representation
*/
getMap(): Map<string, Map<string, number>>;
}
//# sourceMappingURL=graph-converters.d.ts.map