@datastructures/graph
Version:
A minimal functional typed implementation of Graph 📈📉
41 lines (40 loc) • 1.15 kB
TypeScript
/**
* Graph 📈📉
* ----
* @description A collection of vertices and edges
* @summary A collection of vertices related by edges
* @note if you desire to add more functionality
* - to this minimal Stack,
* - submit a pull request
*/
export declare type Vertex = {
key: string;
siblings: Vertex[];
addSibling: (vertex: Vertex) => Vertex;
};
export declare type GraphParams = {
directed?: boolean;
vertices?: Vertex[];
edges?: unknown[];
} | undefined;
export declare type GraphRender = {
directed: boolean;
vertices: Vertex[];
edges: unknown[];
};
export declare type GraphFactory = {
directed: boolean;
vertices: Vertex[];
edges: unknown[];
addVertex: (key: unknown) => GraphFactory;
getVertex: (key: unknown) => Vertex;
addEdge: (key1: unknown, key2: unknown) => GraphFactory;
render: () => GraphRender;
};
export declare type Graph = {
directed: boolean;
vertices: Vertex[];
edges: unknown[];
};
export declare const vertex: (key: string, siblings?: any[]) => Vertex;
export declare const graph: ({ directed, vertices, edges }?: GraphParams) => GraphFactory;