I'm seeing a weird problem in fruchterman_reingold.hpp that after the
displacements are calculated for every vertex, it gets down to the loop
where it updates the positions (starting on line 327), and all the
displacements are (0,0) by that point (they had been sensible values up in
the calculation loop). Any idea what I could be doing to cause that? Here
is my code:
struct spring_attractive_force {
template
On Wed, 3 Oct 2012, eric wrote:
I'm seeing a weird problem in fruchterman_reingold.hpp that after the displacements are calculated for every vertex, it gets down to the loop where it updates the positions (starting on line 327), and all the displacements are (0,0) by that point (they had been sensible values up in the calculation loop). Any idea what I could be doing to cause that? Here is my code:
What is the "point" type defined as? Also, if you print out the positions in each iteration, do you have any vertices in the same position, out of your defined range, or anything else unusual? -- Jeremiah Willcock
Oh, sorry. I missed that line of code in my copy-paste: typedef square_topology<>::point_type point; Do you have any suggestions on how to print out the positions? cout doesn't like me passing something of point_type and the member variable "values" is private. I have just been inspecting their values at breakpoints in Visual Studio. I haven't encountered anything out of the ordinary, but I probably haven't seen every value like I could if I could print them out. -- View this message in context: http://boost.2283326.n4.nabble.com/Trouble-w-fruchterman-reingold-tp4636494p... Sent from the Boost - Users mailing list archive at Nabble.com.
By the way, I thought there might be an issue w/ my using a rectangle
topology for the random_graph_layout and then a square topology for the
fructerman_reingold ... so I changed it all to use the rectangle topology,
but that didn't fix the problem.
New code is below:
using namespace boost;
// Declare global types
enum vertex_position_t { vertex_position };
namespace boost { BOOST_INSTALL_PROPERTY(vertex, position); }
//typedef square_topology<>::point_type point;
typedef rectangle_topology<>::point_type point;
struct simple_edge
{
int first, second;
};
struct spring_attractive_force {
template
I can't explain this, but when I changed the VertexList type parameter on adjacency_list (the second parameter) from listS to veS, it started working beautifully. Is that a bug, maybe? -- View this message in context: http://boost.2283326.n4.nabble.com/Trouble-w-fruchterman-reingold-tp4636494p... Sent from the Boost - Users mailing list archive at Nabble.com.
On Thu, 4 Oct 2012, eric wrote:
I can't explain this, but when I changed the VertexList type parameter on adjacency_list (the second parameter) from listS to veS, it started working beautifully.
Is that a bug, maybe?
When you were using listS as the vertex container, you were creating a vertex_index property but not initializing. Thus, the vertex_index values were most likely all zero, and so all vertices were mapped to the same location in the displacement map. Switching to vecS made the vertex_index property auto-generated with correct values, fixing the bug. -- Jeremiah Willcock
Wow, okay ... thank you. I have to admit that this is all a little bit of
voodoo for me. There are a lot of things going on behind the scenes that I
don't understand.
I'm trying to get my toy prototype into what I need it to be, but as soon as
I switch from defining my Vertex this way:
typedef property
Vertex;
to defining it this way:
struct Vertex
{
int property1;
int property2;
};
I start getting this compiler error:
1>c:\program files
(x86)\boost\boost_1_51\boost\graph\detail\adjacency_list.hpp(2540) : error
C2039: 'type' : is not a member of 'boost::property_value
On Thu, 4 Oct 2012, eric wrote:
Wow, okay ... thank you. I have to admit that this is all a little bit of voodoo for me. There are a lot of things going on behind the scenes that I don't understand.
I'm trying to get my toy prototype into what I need it to be, but as soon as I switch from defining my Vertex this way:
typedef property
Vertex;
to defining it this way:
struct Vertex { int property1; int property2; };
I start getting this compiler error:
1>c:\program files (x86)\boost\boost_1_51\boost\graph\detail\adjacency_list.hpp(2540) : error C2039: 'type' : is not a member of 'boost::property_value
' 1> with 1> [ 1> PropertyList=wmain::Vertex, 1> Tag=int 1> ] That comes from "struct vec_adj_list_any_vertex_pa", which I assume is the vector adjacency_list vertex property ... accessor? Anyway, I don't know how to get my property_value to have a "::type" ... or where the property_value comes from in the first place, for that matter.
property_value is a traits class that looks up the type information about a property map. I don't know why Tag is set to "int"; it would usually have the name of the property map that is not being found (likely vertex_index_t in your case). That might be elsewhere in the instantiation stack, though.
Could you help me understand? Or if there is something I could read that would clear it all up for me, that would be awesome, too. I trolled through the docs, but haven't hit on something that makes me understand what is going on.
I don't know if there is a good explanation now, but since you changed the definition of Vertex, you are no longer providing a vertex_index_t property map (assuming you are using listS as vertex container), and so you'll need to provide either that or a displacement map to fruchterman_reingold as an explicit argument. See the vertex_index_map part of http://www.boost.org/doc/libs/1_51_0/libs/graph/doc/fruchterman_reingold.htm... for how to pass a custom vertex index map to the algorithm. -- Jeremiah Willcock
I think that perhaps I no longer have a property_map for vertex position? Does that make sense? I think that happened in a bit of magic that I had to comment out: //enum vertex_position_t { vertex_position }; //namespace boost { BOOST_INSTALL_PROPERTY(vertex, position); } Now, I'm not sure what to pass in as the second parameter to the layout functions like: random_graph_layout(graph, <?>, topology); I'm not sure if the property_map was created for me and I can get it using: get(<?>, graph); Or if I have to create one ... and what the syntax should be for the creation. -- View this message in context: http://boost.2283326.n4.nabble.com/Trouble-w-fruchterman-reingold-tp4636494p... Sent from the Boost - Users mailing list archive at Nabble.com.
I created one like such:
property_map
On Fri, 5 Oct 2012, eric wrote:
I created one like such:
property_map
positionMap; minstd_rand gen; Topology rect_top(gen, -25, -25, 25, 25); random_graph_layout(patentGraph, positionMap, rect_top); and I get the following errors:
1>c:\program files (x86)\boost\boost_1_51\boost\graph\detail\adjacency_list.hpp(2540) : error C2039: 'type' : is not a member of 'boost::property_value
' 1> with 1> [ 1> PropertyList=wmain::Vertex, 1> Tag=boost::rectangle_topology<>::point_type 1> ] 1> c:\program files (x86)\boost\boost_1_51\boost\graph\detail\adjacency_list.hpp(2594) : see reference to class template instantiation 'boost::vec_adj_list_any_vertex_pa::bind_ ' being compiled 1> with 1> [ 1> Tag=boost::rectangle_topology<>::point_type, 1> Graph=Graph, 1> Property=wmain::Vertex 1> ] I should have mentioned before that I am using vecS now:
typedef adjacency_list
Graph;
You need to use the property map name (not its value type) as the second template argument to property_map. If you are using a bundled property now, the second argument should be "Topology::point_type Vertex::*". You also need to get property_map<...>::type (property_map itself is just a metafunction), and you'll need to initialize positionMap with "get(&Vertex::<member name>, patentGraph)". -- Jeremiah Willcock
I changed it to:
property_map
On Fri, 5 Oct 2012, eric wrote:
I changed it to:
property_map
::vertex_descriptor, Topology::point_type> positionMap; minstd_rand gen; Topology rect_top(gen, -25, -25, 25, 25); random_graph_layout(graph, positionMap, rect_top); so that it would conform w/ the description here http://www.boost.org/doc/libs/1_51_0/libs/graph/doc/random_layout.html that says:
IN/OUT: PositionMap position The property map that stores the position of each vertex. The type PositionMap must be a model of Lvalue Property Map such that the vertex descriptor type of Graph is convertible to its key type. Its value type must be Topology::point_type, representing the coordinates of the vertex.
Now I get the error message:
1>c:\program files (x86)\boost\boost_1_51\boost\graph\properties.hpp(222) : error C2039: 'type' : is not a member of 'boost::vertex_property_type<G>' 1> with 1> [ 1> G=unsigned int 1> ] 1> c:\program files (x86)\boost\boost_1_51\boost\graph\properties.hpp(233) : see reference to class template instantiation 'boost::detail::vertex_property_map
' being compiled 1> with 1> [ 1> Graph=unsigned int, 1> PropertyTag=boost::rectangle_topology<>::point_type 1> ] I think what I really need is a comprehensible example. All that I've found in the way of an example is here http://www.boost.org/doc/libs/1_42_0/libs/graph/test/layout_test.cpp . But it contains so much Boost-specific jargony things that it's not really good for a beginner to look at and get the sense of how things work.
Do you have any such examples up your sleeve?
Here are the two I see off-hand in the source tree: - libs/graph/example/fr_layout.cpp - The test_cube() function in libs/graph/test/layout_test.cpp, ignoring everything in the function between the typedef for edge_iterator and the line containing "minstd_rand gen;" (in the trunk version at URL:https://svn.boost.org/svn/boost/trunk/libs/graph/test/layout_test.cpp, look at lines 202-219 in particular). Just that section should be easier to understand. -- Jeremiah Willcock
Thank you! Between your previous reply (which crossed paths w/ my last post) and this one, I'm finally getting somewhere! I have another question, but it's a little unrelated so I'm going to start another thread. -- View this message in context: http://boost.2283326.n4.nabble.com/Trouble-w-fruchterman-reingold-tp4636494p... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
eric
-
Jeremiah Willcock