Ignore:
Timestamp:
Jul 12, 2017, 7:10:32 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Action_Thermostats, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
4a6ef3
Parents:
966ce7
git-author:
Frederik Heber <frederik.heber@…> (05/19/17 13:13:41)
git-committer:
Frederik Heber <frederik.heber@…> (07/12/17 19:10:32)
Message:

Edges may be added and removed in BoostGraphCreator.

  • TESTS: added unit test case on this.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Graph/unittests/BoostGraphCreatorUnitTest.cpp

    r966ce7 re0b960  
    172172  CPPUNIT_ASSERT_EQUAL ((size_t)5, BGCreator->getNumEdges());
    173173};
     174
     175/** Tests whether adding and removing edges works.
     176 */
     177void BoostGraphCreatorTest::addremoveEdgeTest()
     178{
     179  typedef std::pair<int,int> E;
     180
     181  E edges[] = { E(0,1), E(1,2), E(2,3), E(3,4) };
     182  const size_t no_nodes = 5;
     183  BGCreator->graph =
     184      BoostGraphCreator::UndirectedGraph(edges, edges + sizeof(edges) / sizeof(E), no_nodes);
     185  BGCreator->atomids_nodeids +=
     186      make_pair(0,0), make_pair(1,1), make_pair(2,2), make_pair(3,3), make_pair(4,4);
     187  for (size_t i=0;i<no_nodes;++i)
     188    boost::put(boost::get(boost::vertex_name, BGCreator->graph), boost::vertex(i, BGCreator->graph), i);
     189
     190  CPPUNIT_ASSERT_EQUAL ((size_t)5, BGCreator->getNumVertices());
     191  CPPUNIT_ASSERT_EQUAL ((size_t)4, BGCreator->getNumEdges());
     192
     193  bool status;
     194  // remove a valid edge
     195  {
     196    status = BGCreator->removeEdge((atomId_t)0,(atomId_t)1);
     197    CPPUNIT_ASSERT_EQUAL (true, status);
     198    status = BGCreator->addEdge((atomId_t)0,(atomId_t)1);
     199    CPPUNIT_ASSERT_EQUAL (true, status);
     200    // check again whether edge has really been added again
     201    status = BGCreator->removeEdge((atomId_t)0,(atomId_t)1);
     202    CPPUNIT_ASSERT_EQUAL (true, status);
     203    status = BGCreator->addEdge((atomId_t)0,(atomId_t)1);
     204    CPPUNIT_ASSERT_EQUAL (true, status);
     205  }
     206
     207  // remove an invalid edge
     208  {
     209    status = BGCreator->removeEdge((atomId_t)0,(atomId_t)2);
     210    CPPUNIT_ASSERT_EQUAL (false, status);
     211  }
     212
     213  // add a present edge
     214  {
     215    status = BGCreator->addEdge((atomId_t)0,(atomId_t)1);
     216    CPPUNIT_ASSERT_EQUAL (false, status);
     217  }
     218};
Note: See TracChangeset for help on using the changeset viewer.