Which Graphviz Layout Programs Are Supported by graphviz2drawio?

graphviz2drawio supports every Graphviz layout engine installed on your system, passing the layout_prog argument directly to Graphviz via PyGraphviz without restriction.

The hbmartin/graphviz2drawio library converts Graphviz DOT diagrams into draw.io-compatible XML. Unlike converters that limit you to specific algorithms, this tool accepts any Graphviz layout program recognized by your local Graphviz installation. This flexibility allows you to generate hierarchical, radial, circular, or spring-model layouts depending on your diagram's structure.

How Layout Program Selection Works

The library does not validate or restrict layout engines internally. Instead, the convert function in graphviz2drawio/graphviz2drawio.py (lines 13-18) forwards your layout_prog value directly to PyGraphviz's draw method:

svg_graph: bytes | None = graph.draw(prog=layout_prog, format="svg")

This implementation means graphviz2drawio acts as a transparent wrapper. Any string you provide as layout_prog is passed verbatim to Graphviz. If the engine exists on your system, Graphviz renders the SVG; if not, Graphviz raises an error at runtime.

Complete List of Supported Graphviz Layout Engines

Because graphviz2drawio delegates layout to Graphviz, you can use any installed engine. The following table covers the standard layout programs typically available in Graphviz distributions:

  • dot — Hierarchical layouts with directed edges (the default algorithm)
  • neato — Spring-model layouts for undirected graphs using stress minimization
  • fdp — Spring-model layouts optimized for larger undirected graphs
  • sfdp — Scalable spring-model for very large graphs using multi-scale forces
  • twopi — Radial layouts where nodes are placed on concentric circles
  • circo — Circular layouts that arrange nodes in a circular pattern
  • patchwork — Orthogonal squarified treemaps for small sub-graphs
  • osage — Clustered layouts emphasizing compound graph structures
  • nop — No layout processing; preserves original node positions from the input

Practical Code Examples

You specify the layout engine via the layout_prog parameter in the convert function.

Default Hierarchical Layout with dot

When you omit layout_prog, the library typically defaults to dot for standard hierarchical flowcharts:

from graphviz2drawio import graphviz2drawio

xml = graphviz2drawio.convert("examples/flowchart.dot")  # uses dot

print(xml)

Radial Layouts with twopi

For diagrams requiring radial positioning, pass twopi to arrange nodes on concentric rings:

from graphviz2drawio import graphviz2drawio

xml = graphviz2drawio.convert(
    "examples/radial.gv",
    layout_prog="twopi"   # radial layout

)
print(xml)

Circular Arrangements with circo

Use circo for circular layouts where nodes form a ring structure:

from graphviz2drawio import graphviz2drawio

xml = graphviz2drawio.convert(
    open("examples/circle.dot"),   # can be a file handle

    layout_prog="circo"
)
print(xml)

Spring Models with neato and sfdp

For undirected graphs requiring force-directed placement, use neato for standard sizes or sfdp for large datasets:

from graphviz2drawio import graphviz2drawio

# Standard spring model

dot_string = """
graph G {
    A -- B;
    B -- C;
    C -- A;
}
"""
xml = graphviz2drawio.convert(dot_string, layout_prog="neato")
print(xml)

For large graphs exceeding thousands of nodes, switch to the scalable variant:

from graphviz2drawio import graphviz2drawio

xml = graphviz2drawio.convert(
    "large_graph.gv",
    layout_prog="sfdp"
)
print(xml)

Handling Missing Layout Engines

If you specify a layout program that is not installed on your system, Graphviz will raise an execution error when graph.draw() is invoked. The error propagates through PyGraphviz to your Python runtime. Ensure your target layout engine (such as sfdp or osage) is installed and available in your system PATH before calling convert.

Summary

  • graphviz2drawio supports all Graphviz layout engines by forwarding the layout_prog parameter directly to Graphviz via PyGraphviz.
  • The convert function in graphviz2drawio/graphviz2drawio.py (lines 13-18) implements this passthrough behavior.
  • Standard engines include dot, neato, fdp, sfdp, twopi, circo, patchwork, osage, and nop.
  • You specify the engine using the layout_prog argument; if omitted, Graphviz defaults typically apply.
  • Missing engines trigger runtime errors from Graphviz itself, not from graphviz2drawio.

Frequently Asked Questions

Does graphviz2drawio support the dot layout engine?

Yes. The dot engine is fully supported and is typically the default when no layout_prog is specified. It produces hierarchical layouts ideal for flowcharts and directed acyclic graphs.

Can I use custom or third-party Graphviz layout programs?

Yes. Since graphviz2drawio forwards the layout_prog string directly to Graphviz without validation, any executable layout engine installed on your system—including custom or experimental ones—will work as long as Graphviz recognizes it.

What happens if I specify a layout program that isn't installed?

Graphviz will raise an execution error when attempting to render the SVG. This error occurs inside PyGraphviz's graph.draw() method and propagates to your Python code as a runtime exception indicating the program was not found.

Is there a performance difference between layout engines when using graphviz2drawio?

The performance characteristics depend entirely on the selected Graphviz engine, not on graphviz2drawio itself. Algorithms like sfdp are optimized for large graphs, while dot excels at hierarchical structures. The conversion from SVG to draw.io XML adds minimal overhead regardless of the layout engine used.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →