Re: [Seqan-dev] getting vertex descriptors from graphs


Hi Mat,

Property maps are one-way maps from SeqAn's point of view. If you need an efficient reverse map, you have to use a STL map that maps strings to IDs (=VertexDescriptor).

Cheers,
David
Freie Universität Berlin http://www.inf.fu-berlin.de/
Institut für Informatik Phone: +49 30 838 75246
Takustraße 9 Algorithmic Bioinformatics
14195 Berlin Room 021 

Am 12.01.2011 um 14:26 schrieb Mat:

Hi seqan-users!

Anybody could give me a hint on the following problem?

I created a directed graph and added some nodes. Each node has an additional datastructure (VertexProperty - node name and size...) which is linked to each node by a vertexMap.
Now: Later on i would like to add some edges to my graph, so i need two VertexDescriptor's to add an edge.

Is there a standard way to search a vertexMap's via VertexProperties and get the corresponding VertexDescriptor?

One way would be to iterate on the vertexMap and look for a VertexProperty but this might be to slow...

Thanks!

>>>
//EdgeProperty and VertexProperty store additional information...

typedef Graph<Directed<EdgeProperty> > GraphType;
GraphType *contigGraph = new GraphType();

typedef VertexDescriptor<GraphType>::Type TVertexDescriptor;
typedef EdgeDescriptor<GraphType>::Type TEdgeDescriptor;

typedef seqan::String<VertexProperty > TVertexProperty;
TVertexProperty *vertexPropertyMap = new TVertexProperty();

TVertexDescriptor vertDesc1;

...

for(unsigned int n=0;n<numberOfContigs;++n){
     //get a vertex descriptor
     vertDesc1 = addVertex(*m_g);

     //create a vertex property
     VertexProperty vp1;
     vp1.contigId = n;
     vp1.length = length(fragStore.contigStore[n].seq);

     //store descriptor:vertexproperty
     seqan::resizeVertexMap(*m_g, *vertexMap);
     seqan::assignProperty(*vertexMap,vertDesc1,vp1);
}
<<<


<ATT00001..txt>