Magic labeling in graphs: bounds complexity and an application to a variant of TSP