Mathematical Graph representation in JavaScript