[Lemon-user] Fwd: Reverse NodeMap?

Peter A. Kolski Peter.Kolski at physik.TU-Berlin.de
Fri May 11 14:18:30 CEST 2012


If you don't change the keys (string) and you have a huge graph, then an 'unordered map' would be the choice, because as a hash map it's fast:

#include <boost/unordered_map.hpp>

typedef boost::unordered_map< string , Digraph::Node > mapType;
mapType	idNodeMap;			//create a map
Digraph::Node 	nodeOne, nodeTwo;

// Assign Map
idNodeMap.insert( mapType::value_type("elsa", nodeOne) );

// does a node with that name exist?
if ( idNodeMap.find("elsa") != idNode.end() ) 
	nodeTwo = idNodeMap.at("elsa"); // assign nodeOne = nodeTwo


Have fun!

Peter A. Kolski

Dipl. Phys.
------------------------------------------------------------
Friedrich-Loeffler-Institut
Federal Research Institute for Animal Health

Seestr. 55
16868 Wusterhausen

+49 (0) 33979 80 -182
------------------------------------------------------------
http://www.fli.bund.de/no_cache/de/startseite/institute/institut-fuer-epidemiologie.html
------------------------------------------------------------
BildPeter.de
------------------------------------------------------------

Am 11.05.2012 um 11:21 schrieb Attila Bernáth:

> If I see well, the best thing you can do is to fill a
> std::map< std::string, Digraph::Node >
> (where Digraph is the digraph type you use).
> 
> Attila
> 
> 2012/5/11 BEVAN KOOPMAN <bevan.koopman at student.qut.edu.au>:
>> Hi,
>> 
>> I have the following digraph and associated NodeMap:
>> 
>> ListDigraph g;
>> ListDigraph::NodeMap<string> names(g);
>> 
>> // nodes added, names assigned
>> 
>> // graph serialised to graph.lgf
>> 
>> Then in another program graph.lgf is read in.
>> 
>> My question is: how can a I find the node associated with a given name, i.e. I need a name -> node mapping rather than NodeMap node -> name mapping?
>> 
>> Thanks.
>> 
>> 
>> --
>> Bevan Koopman, PhD Candidate
>> Australian e-Health Research Centre, CSIRO
>> Queensland University of Technology (QUT)
>> [E]: bevan.koopman at csiro.au [T]: (61) 7 3253 3635
>> [W]: http://koopman.id.au   [L]: Brisbane, Australia
>> _______________________________________________
>> Lemon-user mailing list
>> Lemon-user at lemon.cs.elte.hu
>> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user
>> 
> _______________________________________________
> Lemon-user mailing list
> Lemon-user at lemon.cs.elte.hu
> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20120511/7b8af034/attachment.html>


More information about the Lemon-user mailing list