for my $k (keys %$switches) { $g->add_edge($k => $_) for @{$switches->{$k}}; }