Boost logo

Boost Users :

From: Andreas Brinck (Andreas.Brinck_at_[hidden])
Date: 2005-10-11 09:25:01


Hi,

I have a simple directed graph class (let's call it MyGraph) which I want to adapt for BGL algorithms. I've defined the necessary traits and functions (in_edges, target etc.) and everything works fine.

Problem is I want to be able to treat the graph as an undirected graph as well when using some of the BGL algorithms, but since the graph_traits are only templatized on the graph type I can't define a new set of traits since graph_traits<MyGraph> is already defined.

The only solution I've come up with so far (after 10 minutes of thinking :) is to define a new class, MyDirectedGraph, which is an exact copy of MyGraph and define a set of traits for this new class. And then when I want to use the undirected version of the algorithms on my MyGraph object I cast it to a MyDirectedGraph. Somehow I have a feeling there must be a more robust and elegant way to solve this problem.

Regards

/A.B.
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/


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