DNA is negatively charged and therefore attracted towards the positively charged end and therefore it moves from the cathode (the negatively charged end) towards the anode (positively charged end) in an electric field. In the given diagram the DNA fragments move from the end A towards the end B in the gel and hence the end B is the anode end.