ctkDependencyGraphTest1.cpp 1.8 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. //-----------------------------------------------------------------------------
  16. int ctkDependencyGraphTest1(int argc, char * argv [] )
  17. {
  18. Q_UNUSED(argc);
  19. Q_UNUSED(argv);
  20. const int numberOfVertices = 4;
  21. const int numberOfEdges = 3;
  22. ctkDependencyGraph graph(numberOfVertices,numberOfEdges);
  23. graph.setVerbose(true);
  24. graph.setVerbose(false);
  25. graph.setVerbose(true);
  26. graph.insertEdge(1,2);
  27. graph.insertEdge(2,3);
  28. graph.insertEdge(3,4);
  29. graph.printAdditionalInfo();
  30. graph.printGraph();
  31. int nov = graph.numberOfVertices();
  32. if( nov != numberOfVertices )
  33. {
  34. return EXIT_FAILURE;
  35. }
  36. int noe = graph.numberOfEdges();
  37. if( noe != numberOfEdges + 3 )
  38. {
  39. return EXIT_FAILURE;
  40. }
  41. bool cfc = graph.checkForCycle();
  42. if( cfc == true )
  43. {
  44. return EXIT_FAILURE;
  45. }
  46. bool cdtd = graph.cycleDetected();
  47. if( cdtd == true )
  48. {
  49. return EXIT_FAILURE;
  50. }
  51. int corigin = graph.cycleOrigin();
  52. int cend = graph.cycleEnd();
  53. QList<int> path;
  54. graph.findPath( 1, 4, path );
  55. QList<int> list;
  56. graph.setEdgeListToExclude( list );
  57. graph.shouldExcludeEdge(2);
  58. QList<int> sortedlist;
  59. graph.topologicalSort( sortedlist );
  60. return EXIT_SUCCESS;
  61. }