Datasets:
bench / evals /schema-first /dev /handoff-control-networkx-programme-with-committed-builder /files /conf /graph.py
bench / evals /schema-first /dev /handoff-control-networkx-programme-with-committed-builder /files /conf /graph.py
Download evals/schema-first/dev/handoff-control-networkx-programme-with-committed-builder/files/conf/graph.py from erdostack/bench: direct link, hf CLI and curl.
- Browser
- Download file 474 Bytes
-
https://huggingface.co/datasets/erdostack/bench/resolve/main/evals/schema-first/dev/handoff-control-networkx-programme-with-committed-builder/files/conf/graph.py
- Command line
-
hf download hf://datasets/erdostack/bench/evals/schema-first/dev/handoff-control-networkx-programme-with-committed-builder/files/conf/graph.py
-
curl -L -o graph.py https://huggingface.co/datasets/erdostack/bench/resolve/main/evals/schema-first/dev/handoff-control-networkx-programme-with-committed-builder/files/conf/graph.py
474 Bytes
| """Read data/programme.json back into a graph.""" | |
| import json | |
| from pathlib import Path | |
| import networkx as nx | |
| from .build import OUT | |
| def load(path=OUT): | |
| raw = json.loads(Path(path).read_text(encoding="utf-8")) | |
| G = nx.DiGraph() | |
| for node in raw["nodes"]: | |
| attrs = dict(node) | |
| G.add_node(attrs.pop("id"), **attrs) | |
| for edge in raw["edges"]: | |
| attrs = dict(edge) | |
| G.add_edge(attrs.pop("from"), attrs.pop("to"), **attrs) | |
| return G | |