#!/usr/bin/perl use strict; use warnings; use GraphViz; my $g = GraphViz->new(); my $switches = { 'switch0' => ['switch1', 'switch2', 'switch3'], 'switch1' => ['switch4'], }; for my $k (keys %$switches) { $g->add_edge($k => $_) for @{$switches->{$k}}; } print $g->as_text;