Ignore:
Timestamp:
Jul 5, 2017, 7:43:00 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_oldresults, IndependentFragmentGrids_IntegrationTest
Children:
effdea
Parents:
6e1c14
git-author:
Frederik Heber <frederik.heber@…> (05/19/17 13:13:41)
git-committer:
Frederik Heber <frederik.heber@…> (07/05/17 19:43:00)
Message:

Edges may be added and removed in BoostGraphCreator.

  • TESTS: added unit test case on this.
Location:
src/Graph/unittests
Files:
2 edited

Legend:

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

    r6e1c14 rd619f5c  
    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};
  • TabularUnified src/Graph/unittests/BoostGraphCreatorUnitTest.hpp

    r6e1c14 rd619f5c  
    2828    CPPUNIT_TEST ( createFromMoleculeTest );
    2929    CPPUNIT_TEST ( createFromAtomsTest );
     30    CPPUNIT_TEST ( addremoveEdgeTest );
    3031    CPPUNIT_TEST_SUITE_END();
    3132
     
    3738      void createFromMoleculeTest();
    3839      void createFromAtomsTest();
     40      void addremoveEdgeTest();
    3941
    4042private:
Note: See TracChangeset for help on using the changeset viewer.