generalize graph in js to accept different data