Spec-Zone.ru › Graphviz

JSON

Нотация объектов JavaScript

Эти форматы создают выходные данные JSON, кодирующие язык DOT.

  • json0 создаёт выходные данные в формате JSON, содержащие ту же информацию, что и -Tdot.
  • json создаёт выходные данные в формате JSON, содержащие ту же информацию, что и -Txdot.

Для обоих форматов предполагается, что к графу был применён один из алгоритмов размещения.

dot_json и xdot_json также создают выходные данные JSON, подобные json0 и json соответственно, однако используют только содержимое графа на входе. В частности, в них не предполагается, что к графу был применён какой-либо алгоритм размещения; единственная информация xdot в выходных данных присутствовала в исходном входном файле.

Выходные данные этих форматов соответствуют приведённой ниже схеме JSON. Обратите внимание, что массив objects сначала содержит все подграфы, а затем все узлы. Значение _gvid — это индекс подграфа или узла в массиве objects. То же относится к рёбрам в массиве objects. Обратите внимание, что этот формат поддерживает кластеризованные графы, в которых рёбра могут соединять как кластеры, так и узлы.

Пример: простой граф, визуализированный с помощью -Tdot_json
$ echo 'digraph { a->b }' | dot -Tdot_json
{
  "name": "%3",
  "directed": true,
  "strict": false,
  "_subgraph_cnt": 0,
  "objects": [
    {
      "_gvid": 0,
      "name": "a",
      "label": "\\N"
    },
    {
      "_gvid": 1,
      "name": "b",
      "label": "\\N"
    }
  ],
  "edges": [
    {
      "_gvid": 0,
      "tail": 0,
      "head": 1
    }
  ]
}
Пример: простой граф, визуализированный с помощью -Txdot_json
$ echo 'digraph { a->b }' | dot -Txdot_json
{
  "name": "%3",
  "directed": true,
  "strict": false,
  "_subgraph_cnt": 0,
  "objects": [
    {
      "_gvid": 0,
      "name": "a",
      "label": "\\N"
    },
    {
      "_gvid": 1,
      "name": "b",
      "label": "\\N"
    }
  ],
  "edges": [
    {
      "_gvid": 0,
      "tail": 0,
      "head": 1
    }
  ]
}
Пример: простой граф, визуализированный с помощью -Tjson0
$ echo 'digraph { a->b }' | dot -Tjson0
{
  "name": "%3",
  "directed": true,
  "strict": false,
  "bb": "0,0,54,108",
  "_subgraph_cnt": 0,
  "objects": [
    {
      "_gvid": 0,
      "name": "a",
      "height": "0.5",
      "label": "\\N",
      "pos": "27,90",
      "width": "0.75"
    },
    {
      "_gvid": 1,
      "name": "b",
      "height": "0.5",
      "label": "\\N",
      "pos": "27,18",
      "width": "0.75"
    }
  ],
  "edges": [
    {
      "_gvid": 0,
      "tail": 0,
      "head": 1,
      "pos": "e,27,36.104 27,71.697 27,63.983 27,54.712 27,46.112"
    }
  ]
}
Пример: простой граф, визуализированный с помощью -Tjson
echo 'digraph { a->b }' | dot -Tjson
{
  "name": "%3",
  "directed": true,
  "strict": false,
  "_draw_": 
  [
    {
      "op": "c",
      "grad": "none",
      "color": "#fffffe00"
    },
    {
      "op": "C",
      "grad": "none",
      "color": "#ffffff"
    },
    {
      "op": "P",
      "points": [[0.000,0.000],[0.000,108.000],[54.000,108.000],[54.000,0.000]]
    }
  ],
  "bb": "0,0,54,108",
  "xdotversion": "1.7",
  "_subgraph_cnt": 0,
  "objects": [
    {
      "_gvid": 0,
      "name": "a",
      "_draw_": 
      [
        {
          "op": "c",
          "grad": "none",
          "color": "#000000"
        },
        {
          "op": "e",
          "rect": [27.000,90.000,27.000,18.000]
        }
      ],
      "_ldraw_": 
      [
        {
          "op": "F",
          "size": 14.000,
          "face": "Times-Roman"
        },
        {
          "op": "c",
          "grad": "none",
          "color": "#000000"
        },
        {
          "op": "T",
          "pt": [27.000,86.300],
          "align": "c",
          "width": 7.000,
          "text": "a"
        }
      ],
      "height": "0.5",
      "label": "\\N",
      "pos": "27,90",
      "width": "0.75"
    },
    {
      "_gvid": 1,
      "name": "b",
      "_draw_": 
      [
        {
          "op": "c",
          "grad": "none",
          "color": "#000000"
        },
        {
          "op": "e",
          "rect": [27.000,18.000,27.000,18.000]
        }
      ],
      "_ldraw_": 
      [
        {
          "op": "F",
          "size": 14.000,
          "face": "Times-Roman"
        },
        {
          "op": "c",
          "grad": "none",
          "color": "#000000"
        },
        {
          "op": "T",
          "pt": [27.000,14.300],
          "align": "c",
          "width": 7.000,
          "text": "b"
        }
      ],
      "height": "0.5",
      "label": "\\N",
      "pos": "27,18",
      "width": "0.75"
    }
  ],
  "edges": [
    {
      "_gvid": 0,
      "tail": 0,
      "head": 1,
      "_draw_": 
      [
        {
          "op": "c",
          "grad": "none",
          "color": "#000000"
        },
        {
          "op": "b",
          "points": [[27.000,71.700],[27.000,63.980],[27.000,54.710],[27.000,46.110]]
        }
      ],
      "_hdraw_": 
      [
        {
          "op": "S",
          "style": "solid"
        },
        {
          "op": "c",
          "grad": "none",
          "color": "#000000"
        },
        {
          "op": "C",
          "grad": "none",
          "color": "#000000"
        },
        {
          "op": "P",
          "points": [[30.500,46.100],[27.000,36.100],[23.500,46.100]]
        }
      ],
      "pos": "e,27,36.104 27,71.697 27,63.983 27,54.712 27,46.112"
    }
  ]
}
description Представление графа в формате JSON с кодированием атрибутов xdot
title JSON Graphviz
required
  • name
  • directed
  • strict
  • _subgraph_cnt
definitions
drawops
items
oneOf
$ref
#/definitions/ellipse
#/definitions/polygon
#/definitions/polyline
#/definitions/bspline
#/definitions/text
#/definitions/font_style
#/definitions/drawcolor
#/definitions/font
#/definitions/style
type array
style
required
  • op
  • style
type object
properties
style
type string
op
pattern S
type string
font_style
required
  • op
  • fontchar
type object
properties
op
pattern t
type string
fontchar
minimum 0
type integer
maximum 127
polygon
required
  • op
  • points
type object
properties
points
$ref #/definitions/pointlist
op
pattern [pP]
type string
metanode
required
  • _gvid
  • name
type object
properties
_draw_
$ref #/definitions/drawops
name
type string
description Имя узла или подграфа
_ldraw_
$ref #/definitions/drawops
_gvid
type integer
subgraphs
items
type integer
type array
description Индекс дочернего подграфа
edges
items
type integer
type array
description Индекс ребра в этом подграфе
additionalProperties
type string
nodes
items
type integer
type array
description Индекс узла в этом подграфе
title узел или подграф
color
pattern (#[0-9a-f]*)|(#[0-9a-f]{8})
type string
text
required
  • op
  • pt
  • align
  • text
  • width
type object
properties
text
type string
align
pattern [lcr]
type string
op
pattern T
type string
pt
$ref #/definitions/point
width
type number
point
minItems 2
items
type number
type array
maxItems 2
stop
required
  • frac
  • color
type object
properties
color
$ref #/definitions/color
frac
type number
drawcolor
required
  • op
  • grad
type object
properties
p0
oneOf
$ref
#/definitions/point
#/definitions/point3
p1
oneOf
$ref
#/definitions/point
#/definitions/point3
color
$ref #/definitions/color
stops
items
$ref #/definitions/stop
type array
grad
enum
  • none
  • linear
  • radial
type string
op
pattern [cC]
type string
ellipse
required
  • op
  • rect
type object
properties
rect
$ref #/definitions/rectangle
op
pattern [eE]
type string
bspline
required
  • op
  • points
type object
properties
points
$ref #/definitions/pointlist
op
pattern [bB]
type string
edge
required
  • _gvid
  • tail
  • head
type object
properties
_hldraw_
$ref #/definitions/drawops
_tdraw_
$ref #/definitions/drawops
_draw_
$ref #/definitions/drawops
_ldraw_
$ref #/definitions/drawops
_gvid
type integer
tail
type integer
description _gvid хвостового узла
_tldraw_
$ref #/definitions/drawops
_hdraw_
$ref #/definitions/drawops
additionalProperties
type string
head
type integer
description _gvid головного узла хвоста
title ребро
polyline
required
  • op
  • points
type object
properties
points
$ref #/definitions/pointlist
op
pattern L
type string
font
required
  • op
  • size
  • face
type object
properties
size
minimum 0
type number
op
pattern F
type string
face
type string
point3
minItems 3
items
type number
type array
maxItems 3
rectangle
minItems 4
items
type number
type array
maxItems 4
pointlist
items
$ref #/definitions/point
type array
type object
properties
directed
type boolean
description True, если граф ориентированный
_draw_
$ref #/definitions/drawops
name
type string
description Имя графа
objects
items
$ref #/definitions/metanode
type array
description Подграфы графа, за которыми следуют его узлы
_ldraw_
$ref #/definitions/drawops
strict
type boolean
description True, если граф строгий
edges
items
$ref #/definitions/edge
type array
additionalProperties
type string
_subgraph_cnt
type integer
description Количество подграфов в графе

© 2025 The Graphviz Authors
Licensed under the Eclipse Public License 1.0.
https://www.graphviz.org/docs/outputs/json/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API