Javascript- Graph assignment with classical model