ts-graphviz
    Preparing search index...

    Interface GraphBaseModel<T, K>

    DOT model representing a graph/digraph/subgraph.

    interface GraphBaseModel<
        T extends DotObjectType = DotObjectType,
        K extends AttributeKey = AttributeKey,
    > {
        $$type: T;
        attributes: Readonly<GraphCommonAttributes>;
        comment?: string;
        edges: readonly EdgeModel[];
        id?: string;
        nodes: readonly NodeModel[];
        size: number;
        subgraphs: readonly SubgraphModel[];
        values: readonly [K, Attribute<K>][];
        addEdge(edge: EdgeModel): void;
        addNode(node: NodeModel): void;
        addSubgraph(subgraph: SubgraphModel): void;
        apply(attributes: AttributesObject<K> | AttributesEntities<K>): void;
        clear(): void;
        createEdge(
            targets: EdgeTargetLikeTuple,
            attributes?: EdgeAttributesObject,
        ): EdgeModel;
        createNode(id: string, attributes?: NodeAttributesObject): NodeModel;
        createSubgraph(
            id?: string,
            attributes?: SubgraphAttributesObject,
        ): SubgraphModel;
        createSubgraph(attributes?: SubgraphAttributesObject): SubgraphModel;
        delete(key: K): void;
        edge(
            targets: EdgeTargetLikeTuple,
            callback?: (edge: EdgeModel) => void,
        ): EdgeModel;
        edge(
            targets: EdgeTargetLikeTuple,
            attributes: EdgeAttributesObject,
            callback?: (edge: EdgeModel) => void,
        ): EdgeModel;
        edge(attributes: EdgeAttributesObject): void;
        existEdge(edge: EdgeModel): boolean;
        existNode(nodeId: string): boolean;
        existSubgraph(subgraph: SubgraphModel): boolean;
        get<K extends AttributeKey>(key: K): undefined | Attribute<K>;
        getNode(id: string): undefined | NodeModel;
        getSubgraph(id: string): undefined | SubgraphModel;
        graph(attributes: SubgraphAttributesObject): void;
        node(id: string, callback?: (node: NodeModel) => void): NodeModel;
        node(
            id: string,
            attributes: NodeAttributesObject,
            callback?: (node: NodeModel) => void,
        ): NodeModel;
        node(attributes: NodeAttributesObject): void;
        removeEdge(edge: EdgeModel): void;
        removeNode(node: string | NodeModel): void;
        removeSubgraph(subgraph: SubgraphModel): void;
        set<K extends AttributeKey>(key: K, value: Attribute<K>): void;
        subgraph(
            id: string,
            callback?: (subgraph: SubgraphModel) => void,
        ): SubgraphModel;
        subgraph(
            id: string,
            attributes: SubgraphAttributesObject,
            callback?: (subgraph: SubgraphModel) => void,
        ): SubgraphModel;
        subgraph(
            attributes: SubgraphAttributesObject,
            callback?: (subgraph: SubgraphModel) => void,
        ): SubgraphModel;
        subgraph(callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
        with(models: Partial<ModelsContext>): void;
    }

    Type Parameters

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    $$type: T

    The type of the DotObjectType.

    attributes: Readonly<GraphCommonAttributes>
    comment?: string

    Comments to include when outputting with toDot.

    edges: readonly EdgeModel[]

    Edge objects in the graph.

    id?: string
    nodes: readonly NodeModel[]

    Node objects in the graph.

    size: number

    Size of the set of keys and values held by the DOT object.

    subgraphs: readonly SubgraphModel[]

    Subgraph objects in the graph.

    values: readonly [K, Attribute<K>][]

    The key/value tuples of the object attributes.

    Methods

    • Delete the value of an attribute from a DOT object by specifying a key.

      Parameters

      • key: K

      Returns void

    • Create a edge.

      By specifying a callback function, the target edge can be received and manipulated as an argument.

      const G = digraph('G', (g) => {
      // Create a edge.
      g.edge(['a', 'b']);
      });

      console.log(toDot(G));
      // digraph "G" {
      // "a" -> "b";
      // }

      Parameters

      Returns EdgeModel

    • Create a edge and adapt the attributes.

      By specifying a callback function, the target edge can be received and manipulated as an argument.

      const G = digraph('G', (g) => {
      // Create a edge and specifying its attributes.
      g.edge(['a', 'b'], {
      [attribute.color]: 'red',
      [attribute.label]: 'my label',
      });
      });

      console.log(toDot(G));
      // digraph "G" {
      // "a" -> "b" [
      // color = "red",
      // label = "my label",
      // ];
      // }

      Parameters

      Returns EdgeModel

    • Set a common attribute for the edges in the graph.

      const G = digraph('G', (g) => {
      // Set a common attribute for the edges in the graph.
      g.edge({
      [attribute.color]: 'red',
      [attribute.label]: 'my label',
      });
      });

      console.log(toDot(G));
      // digraph "G" {
      // edge [
      // color = "red",
      // label = "my label",
      // ];
      // }

      Parameters

      Returns void

    • Check if the Node exists in the graph.

      Parameters

      • nodeId: string

      Returns boolean

    • Get Node in cluster by specifying id.

      If there is no Node with the specified id in the graph, return undefined.

      Parameters

      • id: string

      Returns undefined | NodeModel

    • Get Subgraph in cluster by specifying id.

      If there is no Subgraph with the specified id in the graph, return undefined.

      Parameters

      • id: string

      Returns undefined | SubgraphModel

    • Set a common attribute for the graph in the graph.

      const G = digraph('G', (g) => {
      g.graph({
      [attribute.color]: 'red',
      [attribute.label]: 'my label',
      });
      });

      console.log(toDot(G));
      // digraph "G" {
      // graph [
      // color = "red",
      // label = "my label",
      // ];
      // }

      Parameters

      Returns void

    • Create a node by specifying its id (or get it if it already exists).

      By specifying a callback function, the target node can be received and manipulated as an argument.

      const G = digraph('G', (g) => {
      // Create a node with id as A.
      g.node('A');
      });

      console.log(toDot(G));
      // digraph "G" {
      // "A";
      // }

      Parameters

      • id: string

        Node ID.

      • Optionalcallback: (node: NodeModel) => void

        Callbacks for manipulating created or retrieved node.

      Returns NodeModel

    • Create a node (or get one if it already exists) and adapt the attributes.

      By specifying a callback function, the target node can be received and manipulated as an argument.

      const G = digraph('G', (g) => {
      // Create a node by specifying its id and specifying its attributes.
      g.node('A', {
      [attribute.color]: 'red',
      [attribute.label]: 'my label',
      });
      });

      console.log(toDot(G));
      // digraph "G" {
      // "A" [
      // color = "red",
      // label = "my label",
      // ];
      // }

      Parameters

      • id: string

        Node ID.

      • attributes: NodeAttributesObject

        Object of attributes to be adapted to the node.

      • Optionalcallback: (node: NodeModel) => void

        Callbacks for manipulating created or retrieved node.

      Returns NodeModel

    • Set a common attribute for the nodes in the graph.

      const G = digraph('G', (g) => {
      // Set a common attribute for the nodes in the graph.
      g.node({
      [attribute.color]: 'red',
      [attribute.label]: 'my label',
      });
      });

      console.log(toDot(G));
      // digraph "G" {
      // node [
      // color = "red",
      // label = "my label",
      // ];
      // }

      Parameters

      Returns void

    • Create a subgraph by specifying its id (or get it if it already exists).

      By specifying a callback function, the target subgraph can be received and manipulated as an argument.

      const G = digraph('G', (g) => {
      // Create a cluster with id as A.
      g.subgraph('A', (A) => {
      // Create a node with id as A1 in cluster A.
      A.node('A1');
      });
      });

      console.log(toDot(G));
      // digraph "G" {
      // subgraph "A" {
      // "A1";
      // }
      // }

      Parameters

      • id: string

        Subgraph ID.

      • Optionalcallback: (subgraph: SubgraphModel) => void

        Callbacks for manipulating created or retrieved subgraph.

      Returns SubgraphModel

    • Create a subgraph (or get one if it already exists) and adapt the attributes.

      By specifying a callback function, the target subgraph can be received and manipulated as an argument.

      const G = digraph('G', (g) => {
      // Create a cluster with id as A and specifying its attributes.
      g.subgraph('A', { [attribute.color]: 'red', [attribute.label]: 'my label' }, (A) => {
      // Create a node with id as A1 in cluster A.
      A.node('A1');
      });
      });

      console.log(toDot(G));
      // digraph "G" {
      // subgraph "A" {
      // color = "red";
      // label = "my label";
      // "A1";
      // }
      // }

      Parameters

      • id: string

        Subgraph ID.

      • attributes: SubgraphAttributesObject

        Object of attributes to be adapted to the subgraph.

      • Optionalcallback: (subgraph: SubgraphModel) => void

        Callbacks for manipulating created or retrieved subgraph.

      Returns SubgraphModel

    • Create anonymous subgraphs and and adapt the attributes.

      By specifying a callback function, the target subgraph can be received and manipulated as an argument.

      const G = digraph('G', (g) => {
      // Create a anonymous cluster and specifying its attributes.
      g.subgraph({ [attribute.color]: 'red', [attribute.label]: 'my label' }, (A) => {
      // Create a node with id as A1 in anonymous cluster.
      A.node('A1');
      });
      });

      console.log(toDot(G));
      // digraph "G" {
      // subgraph {
      // color = "red";
      // label = "my label";
      // "A1";
      // }
      // }

      Parameters

      • attributes: SubgraphAttributesObject

        Object of attributes to be adapted to the subgraph.

      • Optionalcallback: (subgraph: SubgraphModel) => void

        Callbacks for manipulating created or retrieved subgraph.

      Returns SubgraphModel

    • Create anonymous subgraphs and manipulate them with callback functions.

      By specifying a callback function, the target subgraph can be received and manipulated as an argument.

      Parameters

      • Optionalcallback: (subgraph: SubgraphModel) => void

        Callbacks for manipulating created or retrieved subgraph.

      Returns SubgraphModel