create graph directly from array