Please read
Markup in the Monastery, and put
<code>...</code> tags around your code.
You probably don't want to assing [] to @sub - that way the array doesn't become empty, but holds a single value, which is a reference to an empty array. Use @sub = () instead.
Also you'll probably want $graph[$i] = \@sub (no my before it. You're assigning to a part of an existing data structure, declaring a new variable doesn't make sense in that context).
Also please read perllol, which talks about arrays of array references.