DOT (.gv, .dot)

DOT graph language and data format.
Commonly used exchange format for graphs.
Stores a single attributed, directed, or undirected graph.
Can contain user-defined graph, edge, and vertex attributes.
Plain text format.
Developed by AT&T Bell Laboratories.

Import and ExportImport and Export

  • Import["file.gv"] gives a Graph object representing the graph stored in the specified file.
  • Export["file.gv", expr] exports an adjacency matrix or edge information representing a graph to the DOT format.
  • Import["file.gv"] imports the graph from file and returns it as a Graph.
  • Import["file.gv", elem] imports the specified element from a DOT file.
  • Import["file.gv", {{elem1, elem2, ...}}] imports multiple elements.
  • The import format can be specified with Import["file", "DOT"] or Import["file", {"DOT", elem, ...}].
  • Export["file.gv", expr, elem] creates a DOT file by treating expr as specifying element elem.
  • Export["file.gv", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each as specifying the corresponding .
  • Export["file.gv", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.gv", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the DOT file format.

ElementsElements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "AdjacencyMatrix"edge information, given as a matrix
    "EdgeAttributes"edge attributes, represented as a list of rules
    "EdgeRules"connectivity data for the graph, given as a list of rules
    "Graph"graph stored in the file, given as a Graph object
    "GraphAttributes"graph attributes, represented as a list of rules
    "Graphics"graph stored in the file, rendered as a graph plot
    "VertexAttributes"vertex attributes, represented as a list of rules
    "VertexCount"number of vertices in the graph
    "VertexList"vertices, given as a list of strings
  • Import by default uses the element when importing from DOT.

OptionsOptions

ExamplesExamplesopen allclose all

Basic Examples (6)Basic Examples (6)

Import a Graph object from a DOT file:

In[1]:=
Click for copyable input
Out[1]=

Show the Import elements available from an example file:

In[1]:=
Click for copyable input
Out[1]=

Import the connectivity rules of a graph:

In[1]:=
Click for copyable input
Out[1]=

Export a Graph to the DOT format:

In[1]:=
Click for copyable input
Out[1]=

Export an asymmetric adjacency matrix of a graph to the DOT format:

In[1]:=
Click for copyable input
Out[1]=

Convert a list of edge rules representing an undirected graph to the DOT language:

In[1]:=
Click for copyable input
Out[1]=

Import the list of vertices and the attributes of the vertices and display them in table form:

In[1]:=
Click for copyable input
Out[1]//TableForm=

Export a list of edge rules and edge attributes to the DOT format:

In[1]:=
Click for copyable input
Out[1]=

Import edge rules from a DOT file and plot them as a three-dimensional graph:

In[1]:=
Click for copyable input
Out[1]=
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »