Hi, I have a problem with traversing over all parents of a vertex. If I use (the undocumented?) inv_adjacency_iterator_generator class to return iterators for the parents (predecessors) of a vertex I get a compile error. It worked on an earlier version of the library (in debian testing), but does not work for the latest version(1.31.0). I think the problem is that it can no longer find a suitable constructor. Here is my code: // some typedefs removed...... typedef boost::graph_traits<TaskGraph>::in_edge_iterator InEdgeIterator; typedef boost::adjacency_list<boost::listS, boost::listS, boost::bidirectionalS, VertexProperty, EdgeProperty> TaskGraph; typedef boost::inv_adjacency_iterator_generator<TaskGraph, VertexID, InEdgeIterator>::type ParentsIterator; std::pair<ParentsIterator, ParentsIterator> parents(VertexID v, TaskGraph &tg) { InEdgeIterator e,e_end; tie(e,e_end) = in_edges(v,tg); ParentsIterator c(e),c_end(e_end); // problem here. No suitable constructor. return make_pair(e,e_end); } (Traversing through the children/predecessors works fine.) Regards Peter Aronsson -- _________________________________________________________________ / Peter Aronsson, Phd Student at PELAB (Programming Environments \ | Laboratory ) Department for Computer & Information Science | | Linköping University, Sweden | |=================================================================| | petar@ida.liu.se , phone +46 (0)13-28 1737 Room 3B:490 | \_________________________________________________________________/
I'm sorry, but could I ask you to post a complete C++ program so that I can immediately reproduce the problem. Thanks, Jeremy On Mar 9, 2004, at 5:33 AM, Peter Aronsson wrote:
Hi,
I have a problem with traversing over all parents of a vertex. If I use (the undocumented?) inv_adjacency_iterator_generator class to return iterators for the parents (predecessors) of a vertex I get a compile error. It worked on an earlier version of the library (in debian testing), but does not work for the latest version(1.31.0). I think the problem is that it can no longer find a suitable constructor.
Here is my code:
// some typedefs removed...... typedef boost::graph_traits<TaskGraph>::in_edge_iterator InEdgeIterator; typedef boost::adjacency_list<boost::listS, boost::listS, boost::bidirectionalS, VertexProperty, EdgeProperty> TaskGraph; typedef boost::inv_adjacency_iterator_generator<TaskGraph, VertexID, InEdgeIterator>::type ParentsIterator;
std::pair<ParentsIterator, ParentsIterator> parents(VertexID v, TaskGraph &tg) { InEdgeIterator e,e_end; tie(e,e_end) = in_edges(v,tg); ParentsIterator c(e),c_end(e_end); // problem here. No suitable constructor. return make_pair(e,e_end); }
(Traversing through the children/predecessors works fine.)
Regards Peter Aronsson
-- _________________________________________________________________ / Peter Aronsson, Phd Student at PELAB (Programming Environments \ | Laboratory ) Department for Computer & Information Science | | Linköping University, Sweden | |=================================================================| | petar@ida.liu.se , phone +46 (0)13-28 1737 Room 3B:490 | \_________________________________________________________________/
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Jeremy Siek <jsiek@osl.iu.edu> http://www.osl.iu.edu/~jsiek Ph.D. Student, Indiana University Bloomington C++ Booster (http://www.boost.org) Office phone: (812) 856-1820 _______________________________________________
Jeremy Siek wrote:
I'm sorry, but could I ask you to post a complete C++ program so that I can immediately reproduce the problem.
Thanks, Jeremy
Sure, Here is a shortened version that should produce the error on tg.cpp:62 Regards Peter Aronsson -- _________________________________________________________________ / Peter Aronsson, Phd Student at PELAB (Programming Environments \ | Laboratory ) Department for Computer & Information Science | | Linköping University, Sweden | |=================================================================| | petar@ida.liu.se , phone +46 (0)13-28 1737 Room 3B:490 | \_________________________________________________________________/ #include "tg.hpp" VertexNameMap::type VertexNameProperty(TaskGraph* tg) { boost::vertex_name_t pname; VertexNameMap::type pmap = get(pname, *tg); return pmap; }; VertexUniqueIDMap::type VertexUniqueIDProperty(TaskGraph* tg) { vertex_unique_id_t pname; VertexUniqueIDMap::type pmap = get(pname, *tg); return pmap; }; VertexExecCostMap::type VertexExecCostProperty(TaskGraph* tg) { vertex_execcost_t pname; VertexExecCostMap::type pmap = get(pname, *tg); return pmap; } EdgeCommCostMap::type EdgeCommCostProperty(TaskGraph* tg) { boost::edge_weight_t pname; EdgeCommCostMap::type pmap= get(pname, *tg); return pmap; }; int getCommCost(EdgeID edge,TaskGraph * tg) { return get(EdgeCommCostProperty(tg),edge); } void setCommCost(EdgeID edge, int weight,TaskGraph * tg) { put(EdgeCommCostProperty(tg),edge, weight); } int getTaskID(VertexID v,TaskGraph * tg) { return get(VertexUniqueIDProperty(tg),v); } std::pair<ChildrenIterator, ChildrenIterator> children(VertexID v, TaskGraph &tg) { OutEdgeIterator e,e_end; tie(e,e_end) = out_edges(v,tg); ChildrenIterator c(e,&tg),c_end(e_end,&tg); return make_pair(c,c_end); } std::pair<ParentsIterator, ParentsIterator> parents(VertexID v, TaskGraph &tg) { InEdgeIterator e,e_end; tie(e,e_end) = in_edges(v,tg); ParentsIterator c(e),c_end(e_end); return make_pair(e,e_end); } #ifndef _TASKGRAPH_H #define _TASKGRAPH_H #include <boost/config.hpp> #include <iostream> // for std::cout #include <utility> // for std::pair #include <algorithm> // for std::for_each #include <boost/utility.hpp> // for boost::tie #include <boost/graph/graph_traits.hpp> // for boost::graph_traits #include <boost/graph/adjacency_list.hpp> #include <boost/graph/adjacency_iterator.hpp> #include <boost/graph/graphviz.hpp> //Task graph types using namespace std; using boost::tie; struct vertex_execcost_t { typedef boost::vertex_property_tag kind; }; struct vertex_unique_id_t { typedef boost::vertex_property_tag kind; }; struct edge_result_set_t { typedef boost::edge_property_tag kind; }; typedef boost::property<boost::vertex_name_t,string, boost::property<vertex_execcost_t,float, boost::property<vertex_unique_id_t, int > > > VertexProperty; typedef boost::property<boost::edge_weight_t, int > EdgeProperty; typedef boost::adjacency_list<boost::listS, boost::listS, boost::bidirectionalS, VertexProperty, EdgeProperty> TaskGraph; typedef boost::property_map<TaskGraph,boost::vertex_name_t> VertexNameMap; typedef boost::property_map<TaskGraph,vertex_execcost_t> VertexExecCostMap; typedef boost::property_map<TaskGraph,vertex_unique_id_t> VertexUniqueIDMap; typedef boost::property_map<TaskGraph,boost::edge_weight_t> EdgeCommCostMap; typedef boost::graph_traits<TaskGraph>::vertex_descriptor VertexID; typedef boost::graph_traits<TaskGraph>::vertex_iterator VertexIterator; typedef boost::graph_traits<TaskGraph>::edge_descriptor EdgeID; typedef boost::graph_traits<TaskGraph>::edge_iterator EdgeIterator; typedef boost::graph_traits<TaskGraph>::out_edge_iterator OutEdgeIterator; typedef boost::graph_traits<TaskGraph>::in_edge_iterator InEdgeIterator; typedef boost::adjacency_iterator_generator<TaskGraph, VertexID, OutEdgeIterator>::type ChildrenIterator; typedef boost::inv_adjacency_iterator_generator<TaskGraph, VertexID, InEdgeIterator>::type ParentsIterator; VertexNameMap::type VertexNameProperty(TaskGraph* tg); VertexUniqueIDMap::type VertexUniqueIDProperty(TaskGraph* tg); VertexExecCostMap::type VertexExecCostProperty(TaskGraph* tg); EdgeCommCostMap::type EdgeCommCostProperty(TaskGraph* tg); int getCommCost(EdgeID edge,TaskGraph * tg); void setCommCost(EdgeID edge, int weight,TaskGraph * tg); double getExecCost(VertexID v,TaskGraph * tg); double getExecCost(int uniqueID,TaskGraph * tg); void setExecCost(VertexID v, double weight,TaskGraph * tg); int getTaskID(VertexID v,TaskGraph * tg); std::pair<ChildrenIterator, ChildrenIterator> children(VertexID v, TaskGraph &tg); std::pair<ParentsIterator, ParentsIterator> parents(VertexID v, TaskGraph &tg); #endif
Hi Peter, Thanks for the bug report. I've checked in a fix for this to CVS. With the fix, your parents() function should look like this: std::pair<ParentsIterator, ParentsIterator> parents(VertexID v, TaskGraph &tg) { InEdgeIterator e,e_end; tie(e,e_end) = in_edges(v,tg); ParentsIterator c(e, &tg),c_end(e_end, &tg); return make_pair(c,c_end); } I've also added documentation, the file libs/graph/doc/inv_adjacency_iterator.html, and fixed up adjacency_iterator.html a bit. Cheers, Jeremy On Mar 10, 2004, at 2:20 AM, Peter Aronsson wrote:
Jeremy Siek wrote:
I'm sorry, but could I ask you to post a complete C++ program so that I can immediately reproduce the problem.
Thanks, Jeremy
Sure, Here is a shortened version that should produce the error on tg.cpp:62
Regards Peter Aronsson
-- _________________________________________________________________ / Peter Aronsson, Phd Student at PELAB (Programming Environments \ | Laboratory ) Department for Computer & Information Science | | Linköping University, Sweden | |=================================================================| | petar@ida.liu.se , phone +46 (0)13-28 1737 Room 3B:490 | \_________________________________________________________________/
#include "tg.hpp"
VertexNameMap::type VertexNameProperty(TaskGraph* tg) { boost::vertex_name_t pname; VertexNameMap::type pmap = get(pname, *tg); return pmap; };
VertexUniqueIDMap::type VertexUniqueIDProperty(TaskGraph* tg) { vertex_unique_id_t pname; VertexUniqueIDMap::type pmap = get(pname, *tg); return pmap; };
VertexExecCostMap::type VertexExecCostProperty(TaskGraph* tg) { vertex_execcost_t pname; VertexExecCostMap::type pmap = get(pname, *tg); return pmap; }
EdgeCommCostMap::type EdgeCommCostProperty(TaskGraph* tg) { boost::edge_weight_t pname; EdgeCommCostMap::type pmap= get(pname, *tg); return pmap; };
int getCommCost(EdgeID edge,TaskGraph * tg) { return get(EdgeCommCostProperty(tg),edge); }
void setCommCost(EdgeID edge, int weight,TaskGraph * tg) { put(EdgeCommCostProperty(tg),edge, weight); }
int getTaskID(VertexID v,TaskGraph * tg) { return get(VertexUniqueIDProperty(tg),v); }
std::pair<ChildrenIterator, ChildrenIterator> children(VertexID v, TaskGraph &tg) { OutEdgeIterator e,e_end; tie(e,e_end) = out_edges(v,tg); ChildrenIterator c(e,&tg),c_end(e_end,&tg); return make_pair(c,c_end); }
std::pair<ParentsIterator, ParentsIterator> parents(VertexID v, TaskGraph &tg) { InEdgeIterator e,e_end; tie(e,e_end) = in_edges(v,tg); ParentsIterator c(e),c_end(e_end); return make_pair(e,e_end); } #ifndef _TASKGRAPH_H #define _TASKGRAPH_H
#include <boost/config.hpp> #include <iostream> // for std::cout #include <utility> // for std::pair #include <algorithm> // for std::for_each #include <boost/utility.hpp> // for boost::tie #include <boost/graph/graph_traits.hpp> // for boost::graph_traits #include <boost/graph/adjacency_list.hpp> #include <boost/graph/adjacency_iterator.hpp> #include <boost/graph/graphviz.hpp>
//Task graph types using namespace std;
using boost::tie;
struct vertex_execcost_t { typedef boost::vertex_property_tag kind; };
struct vertex_unique_id_t { typedef boost::vertex_property_tag kind; };
struct edge_result_set_t { typedef boost::edge_property_tag kind; };
typedef boost::property<boost::vertex_name_t,string, boost::property<vertex_execcost_t,float, boost::property<vertex_unique_id_t, int >
VertexProperty;
typedef boost::property<boost::edge_weight_t, int > EdgeProperty;
typedef boost::adjacency_list<boost::listS, boost::listS, boost::bidirectionalS, VertexProperty, EdgeProperty> TaskGraph;
typedef boost::property_map<TaskGraph,boost::vertex_name_t> VertexNameMap; typedef boost::property_map<TaskGraph,vertex_execcost_t> VertexExecCostMap; typedef boost::property_map<TaskGraph,vertex_unique_id_t> VertexUniqueIDMap;
typedef boost::property_map<TaskGraph,boost::edge_weight_t> EdgeCommCostMap;
typedef boost::graph_traits<TaskGraph>::vertex_descriptor VertexID; typedef boost::graph_traits<TaskGraph>::vertex_iterator VertexIterator; typedef boost::graph_traits<TaskGraph>::edge_descriptor EdgeID; typedef boost::graph_traits<TaskGraph>::edge_iterator EdgeIterator;
typedef boost::graph_traits<TaskGraph>::out_edge_iterator OutEdgeIterator; typedef boost::graph_traits<TaskGraph>::in_edge_iterator InEdgeIterator;
typedef boost::adjacency_iterator_generator<TaskGraph, VertexID, OutEdgeIterator>::type ChildrenIterator;
typedef boost::inv_adjacency_iterator_generator<TaskGraph, VertexID, InEdgeIterator>::type ParentsIterator;
VertexNameMap::type VertexNameProperty(TaskGraph* tg);
VertexUniqueIDMap::type VertexUniqueIDProperty(TaskGraph* tg);
VertexExecCostMap::type VertexExecCostProperty(TaskGraph* tg);
EdgeCommCostMap::type EdgeCommCostProperty(TaskGraph* tg);
int getCommCost(EdgeID edge,TaskGraph * tg);
void setCommCost(EdgeID edge, int weight,TaskGraph * tg);
double getExecCost(VertexID v,TaskGraph * tg); double getExecCost(int uniqueID,TaskGraph * tg);
void setExecCost(VertexID v, double weight,TaskGraph * tg);
int getTaskID(VertexID v,TaskGraph * tg);
std::pair<ChildrenIterator, ChildrenIterator> children(VertexID v, TaskGraph &tg);
std::pair<ParentsIterator, ParentsIterator> parents(VertexID v, TaskGraph &tg);
#endif _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Jeremy Siek <jsiek@osl.iu.edu> http://www.osl.iu.edu/~jsiek Ph.D. Student, Indiana University Bloomington C++ Booster (http://www.boost.org) Office phone: (812) 856-1820 _______________________________________________
participants (2)
-
Jeremy Siek
-
Peter Aronsson