reding and adding contraints to the graph