summaryrefslogtreecommitdiffstats
path: root/lass
diff options
context:
space:
mode:
authorlassulus <git@lassul.us>2023-09-04 13:51:04 +0200
committerlassulus <git@lassul.us>2023-09-04 13:51:04 +0200
commitd1d41f9d1fb6d95ed38873bfb61c15de954dd499 (patch)
tree38f5b60318bc814f15d3a585511ca5c59c4e00f4 /lass
parent820e17ca1b7ab863ae69d18f56c042112385ca08 (diff)
l: init graphml2json
Diffstat (limited to 'lass')
-rw-r--r--lass/5pkgs/graphml2json/default.nix12
1 files changed, 12 insertions, 0 deletions
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))
+''