[ library(graphviz) | Reference Manual | Alphabetic Index ]

# write_graph(+Graph, +File, +Format, +Options)

Write a picture of a graph as a file of a given format

Graph
  A graph structure
File
  A file name
Format
  An atom (dot,gv,eps,gif,jpg,pdf,png,svg,...)
Options
  A list of Option:Value pairs

## Description

This predicate takes a graph, applies one of the graphviz layout routines to it, and writes the result to a file is a given format.

Possible options are as specified in view_graph/2.

Some possible formats are:

dot,gv,xdot
  Graphviz own formats
eps
  Encapsulated Postscript
gif
  GIF bitmaps
jpg
  JPEG compressed images
pdf
  PDF Portable Document Format
plain
  A human-readable representation
png
  PNG (Portable Network Graphics)
svg
  SVG Scalable Vector Graphics

Many of these formats can be displayed by web browsers or by dedicated viewers. See the graphviz documentation for details and additional formats.

### Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

## Examples

        ?- lib(graph_algorithms), lib(graphviz).
        Yes (1.17s cpu)

        ?- make_random_graph(10,30,true,true,true,G),
           write_graph(G, "mygraph", png).
        G = graph(...)
        Yes (0.03s cpu)

        ?- make_random_graph(10,30,true,true,true,G),
           write_graph(G, "mygraph", dot).
        G = graph(...)
        Yes (0.03s cpu)

## See Also

write_graph / 2, write_graph / 3, view_graph / 2, library(graph_algorithms)