(path, node)
| 64 | json.dump(j, f, indent=2) |
| 65 | |
| 66 | def remove_node(path, node): |
| 67 | _validate(path) |
| 68 | with open(path, "r") as f: |
| 69 | j = json.load(f) |
| 70 | assert node in j["V"], "node not present" |
| 71 | j["V"].remove(node) |
| 72 | # delete associated Vdata and edges |
| 73 | if node in j["Vdata"]: |
| 74 | del j["Vdata"][node] |
| 75 | for edge in j["E"]: |
| 76 | if edge[0] == node or edge[1] == node: |
| 77 | edges.remove(edge) |
| 78 | with open(path, "w") as f: |
| 79 | json.dump(j, f, indent=2) |
| 80 | |
| 81 | def alter_vdata(path, node): |
| 82 | _validate(path) |