Graph

Represents connected information (nodes and edges)

This data type is a way to store non-linear data comprising nodes (vertices) and edges. Graphs are often used to represent networks. The graph structure can be directed or undirected.

Example

The Dot-to-graph adaptor produces a Graph from the graph argument.

Internal Structure

One common way to express a data graph is DOT format. Given the following DOT file:

graph.dot
graph {
  A -- B;
  A -- C;
  B -- C;
  C -- D;
}

An equivalent Graph would be structured as follows:

graph.json
{
    nodes: [
        { id: 'A' },
        { id: 'B' },
        { id: 'C' },
        { id: 'D' }
    ],
    edges: [
        {
            id: 'edge-1',
            from: 'A',
            to: 'B',
            direction: 'none'
        },
        {
            id: 'edge-2',
            from: 'A',
            to: 'C',
            direction: 'none'
        },
        {
            id: 'edge-3',
            from: 'B',
            to: 'C',
            direction: 'none'
        },
        {
            id: 'edge-4',
            from: 'C',
            to: 'D',
            direction: 'none'
        }
    ]

Last updated