FusionAtlasPaths={"~/projects/fusionatlas/package/"};
$Path=$Path~Join~FusionAtlasPaths;
<<FusionAtlas`

SetDirectory[NotebookDirectory[]<>"/.."]

Run["for source in `find . | grep \\.tex$`;do grep -o \"gbg[0-9vpx]*\" $source;done > bigraphs0.list"];
Run["for source in `find . | grep \\.tex$`;do grep -o \"bwd[0-9vpx]*duals[0-9vx]*\" $source;done >> bigraphs0.list"];
Run["sort < bigraphs0.list | uniq > bigraphs.list"];
Run["rm bigraphs0.list"];

graphs=Union[GraphFromString/@ReadList["bigraphs.list",String]];

g=RandomChoice[graphs]

DisplayBigraph[g_,"PNG"]:=Rasterize[Show[Graphics[{AbsolutePointSize[8],AbsoluteThickness[2]}~Join~DisplayBigraph[g][[1]]],AspectRatio->1/GraphDepth[g]],ImageSize->{GraphDepth[g]50,50},Background->None]

DisplayBigraph[g,"PNG"]

SetDirectory["diagrams/bigraphs/"];

Export[GraphToString[#]<>".png",DisplayBigraph[#,"PNG"]]&/@graphs;

Run["whoami > pngcrush.out; date >> pngcrush.out; /opt/local/bin/pngcrush -rem allb -d crushed *.png >> pngcrush.out; mv crushed/*.png .;rmdir crushed"]