import { Brand } from './brand'; import { graphlib } from '@dagrejs/dagre'; import { ui } from '.'; /** * Uniquely identifies as node in the model graph. * * The underlying type is a `string`. Additionally, we use {@link Brand} to provide better type support. * * The following codes creates a {@link NodeId}: * @example * const nodeId = '42' as NodeId; */ export type NodeId = Brand; export interface IEdge { from: NodeId; to: NodeId; } type Edge = { v: NodeId; w: NodeId; }; /** * Represents a network to be visualized by Mycelium. * * Inherits from [graphlib](https://github.com/dagrejs/dagre). * * @example * The following snippet shows how to create a simple network: * ``` * const [a, b, c, d, m, n] = ['a', 'b', 'c', 'd', 'm', 'n'] as Array; * const network = new Network(); * network.setNode(n, new ui.Node(n)); * network.setNodeWithParent(m, new ui.Node(m), n); * network.setNode(a, new ui.Node(a)); * network.setNodeWithParent(b, new ui.Node(b), m); * network.setNodeWithParent(c, new ui.Node(c), m); * network.setNodeWithParent(d, new ui.Node(d), n); * network.setEdge(a, b); * network.setEdge(a, c); * network.setEdge(b, d); * network.setEdge(c, d); * ``` * The information that is shown for each node can be specified in the constructor of {@link ui.Node}. */ export declare class Network extends graphlib.Graph { constructor(graph?: graphlib.Graph); setNodeWithParent(nodeId: NodeId, label: ui.Node, parent: NodeId): void; parents(nodeId: NodeId): Array; hierarchyPreorder(nodeId?: NodeId): Array; hierarchyPostorder(nodeId?: NodeId): Array; /** The types for `graphlib` seem to be wrong so we provide our own `children` * method with correct types. */ childrenT(nodeId: NodeId): Array; parent(nodeId: NodeId): NodeId | undefined; nodes(): Array; modules(): Array; edges(): Array; root(): NodeId; toJson(): object; static readJson(obj: object): Network; } export interface ISelectionOptions { expand: boolean | 'single'; collapseOthers: boolean | { threshold: number; }; } /** @hidden */ export declare function needsModify(network: Network, selection: Array, collapsed: ReadonlySet, options: Partial): { collapse: ReadonlySet; expand: ReadonlySet; }; /** @hidden */ export declare function visibleNodesAndModules(network: Network, collapsed: ReadonlySet): number; export {};