@@ -0,0 +1,1358 @@
+from collections import defaultdict%0Afrom glob   import glob%0Aimport networkx as nx%0Aimport json%0Aimport os%0Afrom pprint import pprint%0Aimport re%0Aimport subprocess%0Aimport sys%0Aimport time%0Aimport uuid%0A%0A%0Adef main():    %0A    universe = nx.read_graphml(sys.argv%5B1%5D)%0A    %0A    beings = filter(lambda x: x%5B1%5D%5B%22type%22%5D == %22Being%22, universe.nodes(data=True))%0A    clients = filter(lambda x: x%5B1%5D%5B%22type%22%5D == %22client%22, universe.nodes(data=True))%0A    firm = filter(lambda x: x%5B1%5D%5B%22type%22%5D == %22firm%22, universe.nodes(data=True))        %0A    print len(beings)%0A    print len(clients)%0A    print len(firm)%0A    %0A    for b in beings:%0A        ns = nx.neighbors(universe,b%5B0%5D)%0A        rep = ns%5B0%5D%0A        for n in ns%5B1:%5D:%0A            for nn in nx.neighbors(universe,n):%0A                universe.add_edge(rep,nn) #doesn't preserve directions or properties, yolo%0A            universe.remove_node(n)%0A        universe.remove_node(b%5B0%5D)%0A        %0A    beings = filter(lambda x: x%5B1%5D%5B%22type%22%5D == %22Being%22, universe.nodes(data=True))%0A    clients = filter(lambda x: x%5B1%5D%5B%22type%22%5D == %22client%22, universe.nodes(data=True))%0A    firm = filter(lambda x: x%5B1%5D%5B%22type%22%5D == %22firm%22, universe.nodes(data=True))        %0A    print len(beings)%0A    print len(clients)%0A    print len(firm)%0A            %0A    nx.write_graphml(universe,%22simplified-%7B%7D.graphml%22.format(int(time.time())))%0Aif __name__ == %22__main__%22:%0A    main()%0A

Convert entity graphs to visually simpler graphs