implementation changed a bit. Square nodes, non weighted graphs