example.cpp 904 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <QFile>
  2. #include <LayoutManager/LayoutManager.h>
  3. int main(int ac, char *argv[])
  4. {
  5. LayoutManager layoutManager;
  6. const char *inf = argv[1];
  7. const char *outf = argv[2];
  8. if(ac==0){}
  9. if (!inf) {
  10. inf = (const char *)"nc.graphml";
  11. }
  12. if (!outf) {
  13. outf= (const char *)"output.graphml";
  14. }
  15. if (0) {
  16. QFile filein (inf);
  17. if (!filein.open (QIODevice::ReadOnly | QIODevice::Text)) {
  18. printf("cannot open in file\n");
  19. return 0;
  20. }
  21. GraphMLReader reader;
  22. SubGraph &gInGraph = reader.readGraphML(&filein);
  23. QFile outFile(outf);
  24. if (!outFile.open(QFile::WriteOnly | QFile::Truncate))
  25. {
  26. cout<<"Write path file could not be open. Exiting.\n";
  27. }
  28. else
  29. {
  30. GraphMLWriter writer;
  31. writer.writeGraphml(gInGraph , &outFile);
  32. }
  33. } else {
  34. layoutManager.applyGridBasedLayout("nc.graphml", "output.graphml"); // outf
  35. }
  36. return 0;
  37. }