From d1d41f9d1fb6d95ed38873bfb61c15de954dd499 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 4 Sep 2023 13:51:04 +0200 Subject: [PATCH] l: init graphml2json --- lass/5pkgs/graphml2json/default.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lass/5pkgs/graphml2json/default.nix diff --git a/lass/5pkgs/graphml2json/default.nix b/lass/5pkgs/graphml2json/default.nix new file mode 100644 index 000000000..6f06ded3d --- /dev/null +++ b/lass/5pkgs/graphml2json/default.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: +pkgs.writers.writePython3Bin "graphml2json" { libraries = [ pkgs.python3Packages.networkx ]; } '' + import networkx as nx + import json + import sys + + + G = nx.read_graphml(sys.argv[1]) + data = nx.readwrite.json_graph.node_link_data(G) + + print(json.dumps(data, indent=2)) +''