ctkDependencyGraphTest1.cxx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*=========================================================================
  2. Library: qCTK
  3. Copyright (c) Kitware Inc.
  4. All rights reserved.
  5. Distributed under a BSD License. See LICENSE.txt file.
  6. This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
  7. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the above copyright notice for more information.
  9. =========================================================================*/
  10. // CTK includes
  11. #include "ctkDependencyGraph.h"
  12. // STL includes
  13. #include <stdlib.h>
  14. #include <iostream>
  15. int ctkDependencyGraphTest1(int argc, char * argv [] )
  16. {
  17. Q_UNUSED(argc);
  18. Q_UNUSED(argv);
  19. const int numberOfVertices = 4;
  20. const int numberOfEdges = 3;
  21. ctkDependencyGraph graph(numberOfVertices,numberOfEdges);
  22. graph.setVerbose(true);
  23. graph.setVerbose(false);
  24. graph.setVerbose(true);
  25. graph.insertEdge(1,2);
  26. graph.insertEdge(2,3);
  27. graph.insertEdge(3,4);
  28. graph.printAdditionalInfo();
  29. graph.printGraph();
  30. int nov = graph.numberOfVertices();
  31. if( nov != numberOfVertices )
  32. {
  33. return EXIT_FAILURE;
  34. }
  35. int noe = graph.numberOfEdges();
  36. if( noe != numberOfEdges + 3 )
  37. {
  38. return EXIT_FAILURE;
  39. }
  40. bool cfc = graph.checkForCycle();
  41. if( cfc == true )
  42. {
  43. return EXIT_FAILURE;
  44. }
  45. bool cdtd = graph.cycleDetected();
  46. if( cdtd == true )
  47. {
  48. return EXIT_FAILURE;
  49. }
  50. int corigin = graph.cycleOrigin();
  51. int cend = graph.cycleEnd();
  52. QList<int> path;
  53. graph.findPath( 1, 4, path );
  54. QList<int> list;
  55. graph.setEdgeListToExclude( list );
  56. graph.shouldExcludeEdge(2);
  57. QList<int> sortedlist;
  58. graph.topologicalSort( sortedlist );
  59. return EXIT_SUCCESS;
  60. }