使用法
$ dot -Tjson input.dot
$ dot -Tjson0 input.dot
$ dot -Tdot_json input.dot
$ dot -Txdot_json input.dot

JSON

JavaScript Object Notation

これらの形式は、DOT言語をエンコードするJSON出力を生成します。

  • json0は、-Tdotによって生成されるのと同じ情報を含むJSON形式で出力を生成します。
  • jsonは、-Txdotによって生成されるのと同じ情報を含むJSON形式で出力を生成します。

これらの両方は、グラフがレイアウトアルゴリズムの1つによって処理されていることを前提としています。

dot_jsonxdot_jsonも、それぞれjson0jsonと同様の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"
    }
  ]
}
説明xdot属性をエンコードするグラフのJSON表現
タイトルGraphviz JSON
必須
  • 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
typearray
style
必須
  • op
  • style
typeobject
properties
style
typestring
op
patternS
typestring
font_style
必須
  • op
  • fontchar
typeobject
properties
op
patternt
typestring
fontchar
minimum0
typeinteger
maximum127
polygon
必須
  • op
  • points
typeobject
properties
points
$ref#/definitions/pointlist
op
pattern[pP]
typestring
metanode
必須
  • _gvid
  • name
typeobject
properties
_draw_
$ref#/definitions/drawops
name
typestring
説明ノードまたはサブグラフの名前
_ldraw_
$ref#/definitions/drawops
_gvid
typeinteger
subgraphs
items
typeinteger
typearray
説明子サブグラフのインデックス
edges
items
typeinteger
typearray
説明このサブグラフ内のエッジのインデックス
additionalProperties
typestring
nodes
items
typeinteger
typearray
説明このサブグラフ内のノードのインデックス
タイトルノードまたはサブグラフ
color
pattern(#[0-9a-f]*)|(#[0-9a-f]{8})
typestring
text
必須
  • op
  • pt
  • align
  • text
  • width
typeobject
properties
text
typestring
align
pattern[lcr]
typestring
op
patternT
typestring
pt
$ref#/definitions/point
width
typenumber
point
minItems2
items
typenumber
typearray
maxItems2
stop
必須
  • frac
  • color
typeobject
properties
color
$ref#/definitions/color
frac
typenumber
drawcolor
必須
  • op
  • grad
typeobject
properties
p0
oneOf
$ref
#/definitions/point
#/definitions/point3
p1
oneOf
$ref
#/definitions/point
#/definitions/point3
color
$ref#/definitions/color
stops
items
$ref#/definitions/stop
typearray
grad
enum
  • none
  • linear
  • radial
typestring
op
pattern[cC]
typestring
ellipse
必須
  • op
  • rect
typeobject
properties
rect
$ref#/definitions/rectangle
op
pattern[eE]
typestring
bspline
必須
  • op
  • points
typeobject
properties
points
$ref#/definitions/pointlist
op
pattern[bB]
typestring
edge
必須
  • _gvid
  • tail
  • head
typeobject
properties
_hldraw_
$ref#/definitions/drawops
_tdraw_
$ref#/definitions/drawops
_draw_
$ref#/definitions/drawops
_ldraw_
$ref#/definitions/drawops
_gvid
typeinteger
tail
typeinteger
説明tailノードの_gvid
_tldraw_
$ref#/definitions/drawops
_hdraw_
$ref#/definitions/drawops
additionalProperties
typestring
head
typeinteger
説明tail headの_gvid
タイトルedge
polyline
必須
  • op
  • points
typeobject
properties
points
$ref#/definitions/pointlist
op
patternL
typestring
font
必須
  • op
  • size
  • face
typeobject
properties
size
minimum0
typenumber
op
patternF
typestring
face
typestring
point3
minItems3
items
typenumber
typearray
maxItems3
rectangle
minItems4
items
typenumber
typearray
maxItems4
pointlist
items
$ref#/definitions/point
typearray
typeobject
properties
directed
typeboolean
説明グラフが有向グラフの場合はTrue
_draw_
$ref#/definitions/drawops
name
typestring
説明グラフ名
objects
items
$ref#/definitions/metanode
typearray
説明グラフのサブグラフの後にグラフのノードが続きます
_ldraw_
$ref#/definitions/drawops
strict
typeboolean
説明グラフがstrictの場合はTrue
edges
items
$ref#/definitions/edge
typearray
additionalProperties
typestring
_subgraph_cnt
typeinteger
説明グラフ内のサブグラフの数