javascript interface - I copied from NetworkX and D3 documentation - I'm begining  to rock