LinuxCommandLibrary

graphml2gv

Convert GraphML files to Graphviz DOT format

TLDR

Convert a graph from gml to gv format

$ graphml2gv -o [output.gv] [input.gml]
copy

Convert a graph using stdin and stdout
$ cat [input.gml] | graphml2gv > [output.gv]
copy

Display help
$ graphml2gv -?
copy

SYNOPSIS

graphml2gv [ -? | -h ] [ -v ] [infile [outfile]]

PARAMETERS

-?
    Print usage information

-h
    Print usage information

-v
    Enable verbose output

infile
    Input GraphML file (stdin if omitted)

outfile
    Output DOT file (stdout if omitted)

DESCRIPTION

graphml2gv is a command-line utility from the Graphviz suite that converts GraphML files—an XML-based graph interchange format—into Graphviz's DOT (.gv or .dot) language. GraphML supports nodes, edges, and attributes, making it popular in tools like yEd or Gephi. This tool bridges GraphML data with Graphviz's layout engines (dot, neato, fdp), enabling visualization, analysis, or further processing.

It reads from infile (or stdin) and writes to outfile (or stdout), mapping basic GraphML elements to DOT syntax. Node/edge labels, IDs, and common attributes are preserved where possible. Ideal for network analysts, data scientists, or developers importing graphs from diverse sources into Graphviz pipelines.

Limitations include partial support for complex GraphML features like hyperedges or custom namespaces, focusing on core directed/undirected graphs.

CAVEATS

Supports basic GraphML only; limited attribute mapping and no hyperedge/extension support.
May require Graphviz version ≥ 2.28.

EXAMPLE

Convert file:
graphml2gv input.graphml > output.dot
Visualize:
dot -Tpng output.dot -o graph.png

INSTALLATION

Install via package manager:
Debian/Ubuntu: sudo apt install graphviz
Fedora: sudo dnf install graphviz

HISTORY

Introduced in Graphviz 2.28 (2009) to enable GraphML import. Maintained as part of the open-source Graphviz project for graph processing interoperability.

SEE ALSO

dot(1), neato(1), gvpr(1), graphviz(1)

Copied to clipboard