JavaScript graph structure: common operations, placing and drawing  on canvas