Base class representing a root graph(digraph, graph).

Hierarchy

Implements

Constructors

  • Parameters

    Returns RootGraph

  • Parameters

    Returns RootGraph

  • Parameters

    Returns RootGraph

  • Parameters

    Returns RootGraph

Properties

#private: any
#private: any
attributes: Readonly<GraphCommonAttributes>
comment?: string

Comments to include when outputting with toDot.

directed: boolean
id?: string
strict: boolean

Strict mode.

Description

A graph may also be described as strict. This forbids the creation of multi-edges, i.e., there can be at most one edge with a given tail node and head node in the directed case. For undirected graphs, there can be at most one edge connected to the same two nodes. Subsequent edge statements using the same two nodes will identify the edge with the previously defined one and apply any attributes given in the edge statement.

Accessors

  • get $$type(): "Graph"
  • The type of the DotObjectType.

    Returns "Graph"

  • get edges(): readonly EdgeModel[]
  • Edge objects in the graph.

    Returns readonly EdgeModel[]

  • get nodes(): readonly NodeModel[]
  • Node objects in the graph.

    Returns readonly NodeModel[]

  • get size(): number
  • Size of the set of keys and values held by the DOT object.

    Returns number

  • get values(): readonly [T, Attribute<T>][]
  • The key/value tuples of the object attributes.

    Returns readonly [T, Attribute<T>][]

Methods

  • Add Edge to the graph.

    Parameters

    Returns void

  • Add a Node to the graph.

    Parameters

    Returns void

  • Add a Subgraph to the graph.

    Parameters

    Returns void

  • Apply keys and values that can be specified for DOT objects collectively.

    Parameters

    Returns void

  • Delete all attributes specified for the DOT object.

    Returns void

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

    Parameters

    • key: values

    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

    • targets: EdgeTargetLikeTuple

      Nodes.

    • Optional callback: ((edge) => void)

      Callbacks for manipulating created or retrieved edge.

        • (edge): void
        • Parameters

          Returns void

    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

    • targets: EdgeTargetLikeTuple
    • attributes: EdgeAttributesObject

      Object of attributes to be adapted to the edge.

    • Optional callback: ((edge) => void)

      Callbacks for manipulating created or retrieved edge.

        • (edge): void
        • Parameters

          Returns void

    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 Edge exists in the graph.

    Parameters

    Returns boolean

  • Check if the Node exists in the graph.

    Parameters

    • nodeId: string

    Returns boolean

  • Check if the Subgraph exists in the graph.

    Parameters

    Returns boolean

  • Get the value of an attribute by a DOT object by specifying its key.

    If the value corresponding to the key does not exist, undefined is returned.

    Type Parameters

    • K extends values

    Parameters

    • key: K

    Returns undefined | Attribute<K>

  • Get Node in cluster by specifying id.

    Parameters

    • id: string

    Returns undefined | NodeModel

    Description

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

  • 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.

    • Optional callback: ((node) => void)

      Callbacks for manipulating created or retrieved node.

        • (node): void
        • Parameters

          Returns void

    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.

    • Optional callback: ((node) => void)

      Callbacks for manipulating created or retrieved node.

        • (node): void
        • Parameters

          Returns void

    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

  • Remove Edge from the graph.

    Parameters

    Returns void

  • Remove Node from the graph.

    Parameters

    Returns void

  • Remove Subgraph from the graph.

    Parameters

    Returns void

  • Set a value, by specifying the key of the attributes in the DOT object.

    Type Parameters

    • K extends values

    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.

    • Optional callback: ((subgraph) => 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.

    • Optional callback: ((subgraph) => 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.

    • Optional callback: ((subgraph) => 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

    • Optional callback: ((subgraph) => void)

      Callbacks for manipulating created or retrieved subgraph.

    Returns SubgraphModel

  • Parameters

    Returns void

Generated using TypeDoc