COIN-OR::LEMON - Graph Library

Ticket #304: 304-1-a4d00df8852e.patch

File 304-1-a4d00df8852e.patch, 4.4 KB (added by Peter Kovacs, 15 years ago)

Bug fixes in the function type interfaces

  • lemon/bfs.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1248726073 -7200
    # Node ID a4d00df8852e1f58f3d8b4339329337dae765162
    # Parent  257e91516e09d8d6be58236c587e3e0199770412
    Fix the interface of bfs(), dfs(), dijkstra() (#304)
    
    diff --git a/lemon/bfs.h b/lemon/bfs.h
    a b  
    11441144    ///\ref named-func-param "Named parameter"
    11451145    ///for getting the shortest path to the target node.
    11461146    template<class T>
    1147     BfsWizard<SetPathBase<T> > path(const T &t)
     1147    BfsWizard<SetPathBase<T> > path(T &t)
    11481148    {
    1149       Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
     1149      Base::_path=reinterpret_cast<void*>(&t);
    11501150      return BfsWizard<SetPathBase<T> >(*this);
    11511151    }
    11521152
     
    11551155    ///
    11561156    ///\ref named-func-param "Named parameter"
    11571157    ///for getting the distance of the target node.
    1158     BfsWizard dist(const int &d)
     1158    BfsWizard dist(int &d)
    11591159    {
    1160       Base::_di=const_cast<int*>(&d);
     1160      Base::_di=&d;
    11611161      return *this;
    11621162    }
    11631163
  • lemon/dfs.h

    diff --git a/lemon/dfs.h b/lemon/dfs.h
    a b  
    10761076    ///\ref named-func-param "Named parameter"
    10771077    ///for getting the DFS path to the target node.
    10781078    template<class T>
    1079     DfsWizard<SetPathBase<T> > path(const T &t)
     1079    DfsWizard<SetPathBase<T> > path(T &t)
    10801080    {
    1081       Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
     1081      Base::_path=reinterpret_cast<void*>(&t);
    10821082      return DfsWizard<SetPathBase<T> >(*this);
    10831083    }
    10841084
     
    10871087    ///
    10881088    ///\ref named-func-param "Named parameter"
    10891089    ///for getting the distance of the target node.
    1090     DfsWizard dist(const int &d)
     1090    DfsWizard dist(int &d)
    10911091    {
    1092       Base::_di=const_cast<int*>(&d);
     1092      Base::_di=&d;
    10931093      return *this;
    10941094    }
    10951095
  • lemon/dijkstra.h

    diff --git a/lemon/dijkstra.h b/lemon/dijkstra.h
    a b  
    12451245    ///\ref named-func-param "Named parameter"
    12461246    ///for getting the shortest path to the target node.
    12471247    template<class T>
    1248     DijkstraWizard<SetPathBase<T> > path(const T &t)
     1248    DijkstraWizard<SetPathBase<T> > path(T &t)
    12491249    {
    1250       Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
     1250      Base::_path=reinterpret_cast<void*>(&t);
    12511251      return DijkstraWizard<SetPathBase<T> >(*this);
    12521252    }
    12531253
     
    12561256    ///
    12571257    ///\ref named-func-param "Named parameter"
    12581258    ///for getting the distance of the target node.
    1259     DijkstraWizard dist(const Value &d)
     1259    DijkstraWizard dist(Value &d)
    12601260    {
    1261       Base::_di=reinterpret_cast<void*>(const_cast<Value*>(&d));
     1261      Base::_di=reinterpret_cast<void*>(&d);
    12621262      return *this;
    12631263    }
    12641264
  • test/bfs_test.cc

    diff --git a/test/bfs_test.cc b/test/bfs_test.cc
    a b  
    150150
    151151  Digraph g;
    152152  bool b;
     153  concepts::Path<Digraph> p;
     154  int d;
    153155  bfs(g).run(Node());
    154156  b=bfs(g).run(Node(),Node());
    155157  bfs(g).run();
     
    164166    .distMap(concepts::ReadWriteMap<Node,VType>())
    165167    .reachedMap(concepts::ReadWriteMap<Node,bool>())
    166168    .processedMap(concepts::WriteMap<Node,bool>())
    167     .path(concepts::Path<Digraph>())
    168     .dist(VType())
     169    .path(p)
     170    .dist(d)
    169171    .run(Node(),Node());
    170172  bfs(g)
    171173    .predMap(concepts::ReadWriteMap<Node,Arc>())
  • test/dfs_test.cc

    diff --git a/test/dfs_test.cc b/test/dfs_test.cc
    a b  
    148148
    149149  Digraph g;
    150150  bool b;
     151  concepts::Path<Digraph> p;
     152  int d;
    151153  dfs(g).run(Node());
    152154  b=dfs(g).run(Node(),Node());
    153155  dfs(g).run();
     
    162164    .distMap(concepts::ReadWriteMap<Node,VType>())
    163165    .reachedMap(concepts::ReadWriteMap<Node,bool>())
    164166    .processedMap(concepts::WriteMap<Node,bool>())
    165     .path(concepts::Path<Digraph>())
    166     .dist(VType())
     167    .path(p)
     168    .dist(d)
    167169    .run(Node(),Node());
    168170  dfs(g)
    169171    .predMap(concepts::ReadWriteMap<Node,Arc>())
  • test/dijkstra_test.cc

    diff --git a/test/dijkstra_test.cc b/test/dijkstra_test.cc
    a b  
    162162
    163163  Digraph g;
    164164  bool b;
     165  concepts::Path<Digraph> p;
     166  VType d;
    165167  dijkstra(g,LengthMap()).run(Node());
    166168  b=dijkstra(g,LengthMap()).run(Node(),Node());
    167169  dijkstra(g,LengthMap())
     
    173175    .predMap(concepts::ReadWriteMap<Node,Arc>())
    174176    .distMap(concepts::ReadWriteMap<Node,VType>())
    175177    .processedMap(concepts::WriteMap<Node,bool>())
    176     .path(concepts::Path<Digraph>())
    177     .dist(VType())
     178    .path(p)
     179    .dist(d)
    178180    .run(Node(),Node());
    179181}
    180182