UNPKG

@graphty/layout

Version:

graph layout algorithms based on networkx

35 lines (34 loc) 909 B
/** * Graph utility functions */ import { Graph, Node, Edge } from '../types'; /** * Extract nodes from a graph object * * @param G - Graph or list of nodes * @returns Array of nodes */ export declare function getNodesFromGraph(G: Graph | Node[]): Node[]; /** * Extract edges from a graph object * * @param G - Graph or list of nodes * @returns Array of edges */ export declare function getEdgesFromGraph(G: Graph | Node[]): Edge[]; /** * Get the degree of a node in the graph * * @param graph - Graph object * @param node - Node to get degree for * @returns Degree of the node */ export declare function getNodeDegree(graph: Graph, node: Node): number; /** * Get the neighbors of a node in the graph * * @param graph - Graph object * @param node - Node to get neighbors for * @returns Array of neighbor nodes */ export declare function getNeighbors(graph: Graph, node: Node): Node[];