Boost logo

Boost Users :

Subject: [Boost-users] [graph] edge container for fast indexing by (bundled) property
From: al.zatv (al.zatv_at_[hidden])
Date: 2011-02-12 21:43:02


Hello! I have a question about Graph library.

Let say I have a tree. Nodes of it are english letters. For example,
A-->B-->X-->C,
     +-->A
     +-->D-->X
I want to find sub-node of any node, by specifying the letter. Is it
possible?

For example, I'am in node B. And I want to find edge and node, by just
saying "give me sub-node from B to the letter D".
Looks like I have to write own EdgeContainer?

Now I did it silly check every sub-node:

***
typedef adjacency_list<listS,listS,bidirectionalS,NodeData> Lattice;
typedef Lattice::vertex_descriptor VertexDesc;
typedef Lattice::edge_descriptor EdgeDesc;

std::tuple<bool,VertexDesc,EdgeDesc> get_sub_letter(const VertexDesc
&n,char letter,const Lattice &lat)
{
     auto outs=out_edges(n,lat);
     auto it=outs.first;
     for (;it!=outs.second;++it)
     {
         VertexDesc targetNode=target(*it,lat);
         if (lat[targetNode].letter==letter)
             return std::make_tuple(true,targetNode,*it);
     }
     return std::make_tuple(false,5,n,*it);
}
***


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