
On Tue, 26 Oct 2010, langermatze wrote:
Hi,
I have a question regarding the boost graph library. I'd like to write a set of depth first search visitors to determine the maximum in/out-degree of a graph. The code should look pretty similar for both cases except for the function call to get the property of the visited node. boost:in_degree(node_id, graph) vs. boost:out_degree(vertexId, graph)
At first glance the function signature pretty much the same, maybe:
template<class Graph> graph_traits<Graph>::degree_size_type function(graph_traits<Graph>::vertex_descriptor u, const Graph &g)
When looking at the BGL headers however, things seem to be a bit more complex, though. I tried to implement a generic dfs_visitor taking a general function pointer to get the in/out degree property of the visited node but I couldn't work out the type of the function pointer to be passed. All my attemtps failed badly. Hopefully, there is anybody on this list who has a better understanding of this business and could provide some help. Any hints/comments are appreciated!
Although using a function pointer would not perform well, you could probably make it work. What errors are you getting? Most likely, you might need an explicit cast from &in_degree to the correct function pointer type for your graph; otherwise, you might get an error like "improper use of overloaded function" or such. -- Jeremiah Willcock