Opened 21 years ago
Closed 21 years ago
#8 closed Bugs (Works For Me)
prop in undirected graph + out_edges
| Reported by: | nobody | Owned by: | jsiek |
|---|---|---|---|
| Milestone: | Component: | graph | |
| Version: | None | Severity: | |
| Keywords: | Cc: |
Description
The following code ( only part of it ) where I tried
to set the property of an edge obtained from an out
edge_iterator:
enum edge_state_t { not_visited, visited };
typedef boost::property<
boost::edge_name_t,
edge_state_t
> edge_property;
typedef boost::adjacency_list<
boost::vecS,
boost::vecS,
boost::undirectedS,
boost::no_property,
edge_property,
boost::no_property
> graph_type;
graph_type g;
boost::property_map<graph_type,boost::edge_name_t>::typ
e edge_state = get(boost::edge_name_t(),g);
out_edge_iterator e, eend;
boost::tie(e, eend) = out_edges(tmpv,g);
for ( ; e != eend; ++e )
if ( edge_state[*e] == not_visited ) {
// Version 1
edge_state[*e] == visited;
// Version 2
edge_state[edge(source(*e,g),targe(*e,g),g).first]
= visited;
tmpv = target(*e,g);
}
Version 2 works, while Version 1 does not ( the
property is not assigned ). I'm not 100% sure that
this should work, but as far as I know the
documentation Version 1 should work as well.
The out_edge_iterator is an ordered pair as the target
vertex is fixed. The "normal" edge is undirected, so
Version 1 seems only to work, when by luck, the
ordered pair corresponds somhow to the unordered one.
Note:
See TracTickets
for help on using tickets.
