in reply to how to localise a problem?

Dot should be perfectly happy with ten nodes... and also with forty

In order to isolate the problem change this:

eval { $self->{graph}->run(format => 'png'); $png = $self->{graph}->dot_output(); };

To this:

eval { $self->{graph}->run(format => 'svg'); $png = $self->{graph}->dot_output(); };

And show us the result (or at least the first and last lines)