def tojson(self): r""" Convert this `LabelledPointUndirectedGraph` to a dictionary JSON representation. Returns ------- json : ``dict`` Dictionary conforming to the LJSON v2 specification. """ labels = [{'mask': mask.nonzero()[0].tolist(), 'label': label} for label, mask in self._labels_to_masks.items()] lms_dict = PointUndirectedGraph.tojson(self) lms_dict['labels'] = labels return lms_dict