l: init graphml2json

This commit is contained in:
lassulus 2023-09-04 13:51:04 +02:00
parent 820e17ca1b
commit d1d41f9d1f
1 changed files with 12 additions and 0 deletions

View File

@ -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))
''