[Graph] Defining coordinates for vertices
Hi,
I can't figure out if it is possible (and if it is, how) to assign
coordinates to graph vertices on planar graphs. I've tried setting the
property vertex_index_t to std::pair
On Wed, Jul 15, 2009 at 4:56 AM, Maxime van Noppen
Hi,
I can't figure out if it is possible (and if it is, how) to assign coordinates to graph vertices on planar graphs. I've tried setting the property vertex_index_t to std::pair
but it doesn't seem to work (make_maximal_planar doesn't use them for example).
<snip>
// The goal is now to make g planar w.r.t. the coordinates
// 1- Either make_connected or add at least one edge to make the graph // connected
// 2- make_biconnected_planar
// 3- make_maximal_planar ------------------
<snip> Hi Maxime, If I understand you correctly, you have a graph that's planar and already know the coordinates of vertices in the plane, and you want to create a planar embedding (cyclic ordering of edges around each vertex) that respects your coordinates? The boyer_myrvold_planarity_test function can create _a_ planar embedding if the input graph is planar, but it sounds like you're looking for a specific planar embedding based off of the coordinates. There's currently no way to give any of the planar graph functions hints about the embedding you'd like to create through coordinates, etc., but if you do create the embedding you want from the coordinates (which you can do without too much trouble if all of the coordinates are specified), the rest of the planar graph functions (like make maximal planar and the chrobak-payne straight line drawing) can be used with the embedding you provide. Regards, Aaron
On 07/15/09 16:47, Aaron Windsor wrote:
Hi Maxime,
Thank for the answer,
If I understand you correctly, you have a graph that's planar and already know the coordinates of vertices in the plane, and you want to create a planar embedding (cyclic ordering of edges around each vertex) that respects your coordinates?
I have a (maximal) planar graph where vertices have coordinates and I want to add new vertices at some precise coordinates and add all possible edges to it to make the graph maximal planar. I'm new to boost::graph and don't fully understand how the planar embedding is used and therefore what should be in it in order to make make_maximal_planar work. -- Maxime
On Thu, Jul 16, 2009 at 8:45 AM, Maxime van Noppen
On 07/15/09 16:47, Aaron Windsor wrote:
Hi Maxime,
Thank for the answer,
If I understand you correctly, you have a graph that's planar and already know the coordinates of vertices in the plane, and you want to create a planar embedding (cyclic ordering of edges around each vertex) that respects your coordinates?
I have a (maximal) planar graph where vertices have coordinates and I want to add new vertices at some precise coordinates and add all possible edges to it to make the graph maximal planar.
I'm new to boost::graph and don't fully understand how the planar embedding is used and therefore what should be in it in order to make make_maximal_planar work.
Given a planar graph G, a planar embedding is an clockwise ordering of the edges adjacent to each vertex as they appear in some drawing of G in the plane. Planar embeddings are not necessarily unique given a particular graph (given a tree, for example, _any_ ordering of edges around vertices creates a valid planar embedding), but a planar embedding serves as a certificate of planarity and is the standard "preprocessing step" in dealing with planar graphs - once you have a planar embedding for a graph, you can pass that planar embedding along with the graph to other functions like make_biconnected_planar, make_maximal_planar, and chrobak_payne_straight_line_drawing. boyer_myrvold_planarity_test can create a planar embedding for you if you give it a planar graph, then you can pass this planar embedding to other functions. A concrete implementation of the planar embedding concept in the BGL would be a vector of vectors of edges: for a vertex with index 5 that has 3 edges adjacent to it, planar_embedding[5][0], planar_embedding[5][1], planar_embedding[5][2] specifies the cyclic order of those edges. In your case, since you already have a plane drawing (given by the coordinates of the vertices in the plane), you don't need boyer_myrvold_planarity_test to tell you that your graph is planar or to create a planar embedding (although it could, it just wouldn't necessarily correspond to the planar embedding implied by your coordinates). But you can still use other functions like make_biconnected_planar and make_maximal_planar - you just need to create the particular planar embedding you have in mind yourself, then pass it to these functions. Functions taking a planar embedding as input will respect the planar embedding that you start from when adding edges/augmenting the embedding. In the specific example you mentioned, if you started with a maximal planar graph + a planar embedding, then added a vertex v somewhere and a few edges adjacent to v, you could still use make_maximal_planar to fill out the rest of the planar embedding as long as you specify at least two edges adjacent to v and add them to the planar embedding first (as this will fix v's relative location in the planar embedding). For example, let's say you have a maximal planar graph G with > 2 vertices and a planar embedding of G, corresponding to a coordinate map that maps all of G's vertices into the the plane. Now you want to add a new vertex v somewhere on the outer face of G - just attach v to 2 other vertices x and y on the outer face of G by adding (v,x) and (v,y) to the graph, insert (v,x) into the planar embedding adjacent to both x and v, and insert (v,y) in the planar embedding adjacent to both y and v. Then call make_maximal_planar, which will add all of the rest of the edges to make the graph maximal planar. Notice that you need to attach x to at least two other vertices, otherwise it's not completely specified whether x lies on the outer face or inside a face. Regards, Aaron
On 07/17/09 03:35, Aaron Windsor wrote:
In the specific example you mentioned, if you started with a maximal planar graph + a planar embedding, then added a vertex v somewhere and a few edges adjacent to v, you could still use make_maximal_planar to fill out the rest of the planar embedding as long as you specify at least two edges adjacent to v and add them to the planar embedding first (as this will fix v's relative location in the planar embedding).
It is much clear now, thanks. So now I've the problem to find those first two edges to add. Unfortunately there is no relation between the coordinates (like a regular mesh or whatever). There is a distance tag, maybe it is of some use to find the closest vertices ? But still, the closest vertices might be in another face. It might be easier for this part to use other means than purely boost::graph to find those points (we have other representations of the mesh that could help). Thank you for this really nice answer though. -- yabo
participants (2)
-
Aaron Windsor
-
Maxime van Noppen