# Newbie: BGL & planar graphs

3 messages
Open this post in threaded view
|

## Newbie: BGL & planar graphs

 Hello everyone!I am using BGL to test for the planarity of drawings of graphs. The coordinates are hardcoded into the source code. Here's what the graph should look like: . This definitely isn't planar and yet is_straight_line_drawing() returns 1! I'm quite confused. Am I doing something wrong? Thank you to anyone who replies.#include #include #include #include #include using namespace boost;typedef struct { size_t x,y; } coord_t;int main(void) {  typedef adjacency_list             > graph;  graph Moser(7);  add_edge(0,1,Moser);  add_edge(0,6,Moser);  add_edge(0,4,Moser);  add_edge(1,6,Moser);  add_edge(1,2,Moser);  add_edge(2,6,Moser);  add_edge(2,5,Moser);  add_edge(2,3,Moser);  add_edge(3,4,Moser);  add_edge(4,5,Moser);  graph G(Moser);  int k = num_vertices(G);  typedef std::vector cvec;  typedef boost::iterator_property_map    ::type // ?     >    foo_t;  cvec v(num_vertices(G));  foo_t drawing(v.begin(), get(vertex_index, G));  coord_t x[k];  x[0].x = 20; x[0].y = 10;  x[1].x = 50; x[1].y = 10;  x[2].x = 58; x[2].y = 52;  x[3].x = 00; x[3].y = 30;  x[4].x = 35; x[4].y = 50;  x[5].x = 12; x[5].y = 51;  x[6].x = 70; x[6].y = 30;  graph_traits::vertex_iterator vi, vi_end;  for(boost::tie(vi, vi_end) = vertices(G); vi != vi_end; ++vi)      put(drawing, *vi, x[*vi]);  if(is_straight_line_drawing(G,drawing))    std::cout << "This is a straight line planar drawing!" << std::endl;  return 0;} _______________________________________________ Boost-users mailing list [hidden email] https://lists.boost.org/mailman/listinfo.cgi/boost-users