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