Boost logo

Boost Users :

Subject: Re: [Boost-users] [Graph] Guarantee on bidirectional graphs
From: Sensei (senseiwa_at_[hidden])
Date: 2014-03-13 11:05:14


On 3/12/14, 6:33pm, alex wrote:
>> From: >Sensei
> ...
>> So, is the order of nodes in an edge guaranteed to generate the correct
>> in/out adjacent nodes? I do not care about ordering of nodes, just
>> distinguishing nodes that belong to in and out edges.
>>
>> For instance,
> ...
>> std::cout << neighbors_out.first->idx << std::endl;
> ...
>> std::cout << neighbors_in.first->idx << std::endl;
>
> I am not familiar with the idx member for edge descriptors. But, since you
> are interested in the target/source of the edge, would it be better to write
> the following?
>
> std::cout << boost::target(*neighbors_out.first, graph) << std::endl;
> std::cout << boost::source(*neighbors_in.first, graph) << std::endl;
>
> Best wishes, Alex

Thanks Alex, that solved the indexing properties!

Do you know if in and out edges are preserved even if the graph is
declared as bidirectional? I just need this guarantee, that for
instance, a graph

     1 -> 2
     2 -> 3
     2 -> 4

will always produce as out edges nodes of 2, the nodes 3 and 4, and as
in edge nodes, just 1. AFAIR, in a bidirectional graph there is no
distinction between in and out edges, so I am worried BGL could
rearrange them for some internal representation reason.

By the way, is there the analog index function for edges as far as you
know? This code works (the ei->idx), but I fear I'm on the edge of a
disaster like I was with the nodes :)

     std::cout << "Dumping graph" << std::endl;
     for (boost::tie(ei, ee) = boost::edges(graph); ei != ee; ei++)
     {
         std::cout << ei->idx << " : " << boost::source(*ei, graph) <<
"-" << boost::target(*ei, graph) << std::endl;
     }

Thanks & Cheers!


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net