SaveGViz(Graph, OutFNm, Desc, NodeLabels, NIdColorH)

Saves Graph to the .DOT file format used by GraphViz. Use ”.dot” as file extension for OutFNm.


  • Graph: graph (input)

    A graph or a network.

  • OutFNm: string (input)

    Name of the output file.

  • Desc: string (input)

    Description of the Graph.

  • NodeLabels: bool (input)

    Indicates whether to show the node labels.

  • NIdColorH: TIntStrH, a hash table with int keys and string values (input)

    Maps node ids to node colors (see GraphViz documentation for more details).

Return value:

  • None

For more info about Graph Viz see:

The following example shows how to save graphs of types TNGraph, TUNGraph, and TNEANet for GraphViz:

import snap

H = snap.TIntStrH()
H.AddDat(1, "blue")
H.AddDat(2, "blue")
H.AddDat(3, "red")
H.AddDat(4, "red")

Graph = snap.GenRndGnm(snap.PNGraph, 4, 6)
snap.SaveGViz(Graph, "", "Directed Random Graph", True, H)

UGraph = snap.GenRndGnm(snap.PUNGraph, 4, 6)
snap.SaveGViz(UGraph, "", "Undirected Random Graph", True, H)

Network = snap.GenRndGnm(snap.PNEANet, 4, 6)
snap.SaveGViz(Network, "", "Directed Random Network with Attributes", True, H)

Previous topic


Next topic


This Page