| 69 | |
| 70 | @classmethod |
| 71 | def get_node_label_str(cls, node): |
| 72 | node_str = str(node.node_id) |
| 73 | label = node.label |
| 74 | if isinstance(label, int): |
| 75 | node_str += " " + str(label) |
| 76 | elif isinstance(label, list): |
| 77 | node_str += " " + " ".join([str(int(x)) for x in label]) |
| 78 | elif isinstance(label, np.ndarray): |
| 79 | label_nnz = np.nonzero(label)[0] |
| 80 | if np.isscalar(label_nnz): |
| 81 | node_str += " " + str(np.asscalar(label_nnz.a)) |
| 82 | else: |
| 83 | node_str += " " + " ".join([str(int(x)) for x in label]) |
| 84 | return node_str |
| 85 | |
| 86 | |
| 87 | class Context: |