1
$\begingroup$

I have a planar graph, for which I have computed a combinatorial embedding and coordinates in the plane. So all my arcs are now oriented in the plane, respective to their end vertices.

Computing a list of all faces of the graph (as a list of oriented walks along their arcs) is fairly straightforward.

On the other hand, finding a simple way to pick the outer face out of the list of faces does not seem as easy: it is included in the list of faces, but since its orientation is "reversed" (i.e. relative to the outer region, rather than the inside of the graph boundary), all its properties in terms of neighbouring faces are identical to other faces.

Short of using plane coordinates to painstakingly identify the outer nodes/arcs of the graph, is there a more straightforward way to pick the outer face out of the list of faces using the combinatorial embedding (given as a table of arc successors in the oriented plane)?

Edit: Upon reading the comments, I realised that my wording was ambiguous (verging on the incorrect): while I have the combinatorial embedding and would like to use it (or the information derived from it), I also have coordinates derived from a drawing of that graph (hence the plane graph, not simply planar graph), ensuring that there is, indeed, a specific outer face.

What I meant to say is that I am looking for a method that would do more (or rather: less) than just looking at the coordinates of all faces and (for example), compute their orientation.

To be precise, the embedding and plane drawing give me:

  • a list of all faces (as an oriented walk of vertices).
  • for each arc: the face left and right of it.
  • for each vertex: an oriented walk of its ingoing/outgoing arcs (actually, my graph of interest is undirected, but that is probably not very relevant).

Edit 2: Despite the upvotes, the first comment does not really solve much (it essentially boils down to a recursive answer: "in order to find the outer face, use the leftmost vertex, then find the outer face", which isn't as trivial to solve as its commenter seemed to think.

@Zsbán provided what looks like the most efficient and elegant solution. Thanks!

$\endgroup$
  • 7
    $\begingroup$ Is there a reason you can't just look at the face to the left of the leftmost vertex? $\endgroup$ – David Eppstein Nov 26 '14 at 8:31
  • 2
    $\begingroup$ @DavidEppstein maybe I misunderstand what you mean but I don't think "face to the left of the leftmost vertex" is well-defined: a face can be to the left of an oriented edge, not a vertex. $\endgroup$ – Noam Zeilberger Nov 26 '14 at 12:14
  • 2
    $\begingroup$ @DavidEppstein I think you might be making additional assumptions which aren't in the usual definition of "embedded plane graph"/"plane map" (e.g., in general the graph can contain loops and multiple edges). Have a look at the two planar maps in the middle of page 2 of labri.fr/perso/zvonkin/Research/belyi.pdf. Does your criterion correctly identify the outer face? $\endgroup$ – Noam Zeilberger Nov 26 '14 at 21:02
  • 3
    $\begingroup$ what I'm saying is that identifying the leftmost vertex does not let one determine the outer face, and that the two maps on p.2 of the article I linked to above are both counterexamples to your suggested algorithm. The map on the left has two faces incident to the leftmost vertex and no criterion as far as I can tell (regardless of knowledge of vertex coordinates) for determining which face is "to the left". The map on the right has only one face incident to the leftmost vertex, but it is actually not the outer face. $\endgroup$ – Noam Zeilberger Nov 27 '14 at 2:04
  • 4
    $\begingroup$ Are your arcs embedded to the plane as straight lines? If so, then after computing the leftmost vertex, you can compute the arc starting from that vertex whose other end is above this arc but the angle of the arc segment is the leftmost among such arcs. The face on the left hand side of this arc is the outer face. If the edges aren't embedded as straight lines, then you need some extra information about the embedding, because in any plane graph you could just take an edge of the outer face and lift it around the whole embedding: this changes the outer face but doesn't move the vertexes. $\endgroup$ – Zsbán Ambrus Nov 27 '14 at 8:13
3
$\begingroup$

First, suppose that your arcs are embedded to the plane as straight lines. Then, the following three step algorithm works.

First, compute the leftmost vertex (as David Eppstein suggested). This vertex will be on the unbounded face.

Second, among the arcs from that vertex, find the one whose slope is largest. This arc will be a side of the unbounded face. (You must consider the slope; taking the arc with the leftmost destination vertex wouldn't work. You may have to handle the case when this vertex is isolated somehow.)

Thirdly, take the face on the left hand side of this arc. That face is the outer face.

If the edges aren't embedded as straight lines, then you need some extra information about the embedding. Indeed, in any plane graph (with at least one cycle), you could just take an edge of the outer face and lift it around the whole embedding. This changes the outer face, but doesn't move the vertexes, and doesn't change the cyclical orientation of arcs from the vertexes.

In particular, if the edges are open polygons given with the coordinates of the list of inner vertexes, then divide each such edge to a path and run the previous algorithm in the subdivided graph. This may choose such an internal vertex in the first step.

$\endgroup$
  • $\begingroup$ This is definitely a huge improvement over my idea (somehow did not occur to me to simply go up, as well as left, and be done with it). One small comment: I am not sure I see what the problem could be with taking the target vertex (connected to $v_1$) that is 1. above (non strictly) $v_1$ and 2. left (non strictly) of $v_1$. Not dealing with angles would make the whole thing a lot easier. Not sure what you mean by an "isolated" vertex... Do you have a specific counter-example in mind? $\endgroup$ – Dave Nov 28 '14 at 1:37
  • $\begingroup$ Never mind my previous comment, I think I see what you meant by "isolated vertex" and how it would pose a problem (the case where the leftmost is also the uppermost?)... But at any rate, perhaps the phrase "leftmost angle arc" needs a better definition: it seems to me that it should be the arc with the largest (direct) angle from vector [0, -1] (vertical, below the vertex). Does that seem correct to you? $\endgroup$ – Dave Nov 28 '14 at 2:35
  • $\begingroup$ I changed the description of the angle thing, the previous description was too complicated. $\endgroup$ – Zsbán Ambrus Nov 28 '14 at 7:57
  • $\begingroup$ Replaced "angle closest to vertical" with "maximum slope". Angles are evil (and numerically unstable). $\endgroup$ – Jeffε Dec 1 '14 at 4:28
2
$\begingroup$

As you are computing a list of all faces of the graph as a list of oriented walks along their arcs (as you've written) you could compute the area of the face (polygon) efficiently as is suggested in the second algorithm here (since you have plane coordinates of the vertices): Area of polygon. The face with largest area should be the outer face of your graph.

About using information only in the combinatorial map, I think Noam Zeilberger is right about that they can be embedded in different ways on the plane. More information about this may be here: Polynomial Algorithms for Subisomorphism of nD Open Combinatorial Maps

$\endgroup$
  • $\begingroup$ This would indeed work, but rather cumbersome (and potentially quite time-consuming, even if it remains O(n))... However, this inspired me toward a working solution that required a lot less effort, so thanks for pitching in! $\endgroup$ – Dave Nov 27 '14 at 7:52
0
$\begingroup$

Edit: actually, step 2 is wrong (see comments). Anyway, the accepted answer solves this much more elegantly.

Since there does not seem to be any (straightforward/simple) answer so far, I thought I would post what I came up with, with inspiration taken from @DavidEppstein's comment and @kudy's answer:

Figuring out the leftmost/rightmost point indeed seems to be a good start. However, from there, @DavidEppstein's idea is unfortunately not applicable (there is no straightforward way to know the face "left of a vertex" in the plane). Instead this is what I do:

  1. Find rightmost point $v_1$ of graph in the plane.

  2. Find rightmost point $v_2$ connected to $v_1$.

  3. Take the two faces bordering edge [$v_1$,$v_2$]. Let the longer one (in number of vertices) be $F_a$ and the other one $F_b$.

  4. Pick an arc $A_a$ in $F_a$ that is not in $F_b$ (we know there is such an arc since the two faces cannot be identical and $F_a$ is longer than $F_b$).

  5. If the middle of $A_a$ is inside the polygon formed by the vertices of $F_b$ in the plane, $F_b$ is the outer face, otherwise $F_a$ is.

I welcome any comment and improvement to the method!

$\endgroup$
  • 1
    $\begingroup$ I think this won't work as is, because v_2 may be a vertex not on the outer face. It can be fixed to work though. $\endgroup$ – Zsbán Ambrus Nov 27 '14 at 14:32
  • $\begingroup$ Are you certain? We know that $v_1$ is on the outer face. Therefore if $v_2$ is not, it would be inside the outer face and there would be a vertex connected to $v_1$ that is more to the right than $v_2$... $\endgroup$ – Dave Nov 28 '14 at 1:24
  • 1
    $\begingroup$ (Sorry, let me try again.) No, this doesn't work; the righmost neighbor of the righmost vertex can be in the interior. Imagine a tiny tiny horizontal edge to the left of the rightmost vertex. $\endgroup$ – Jeffε Dec 1 '14 at 13:12
  • $\begingroup$ @JɛffE: thanks for the clarification: you mean e.g. a horizontal edge left of $v_1$ while the real outer edges go farther left (the 'tiny tiny' part kind of threw me off). Indeed, that's a problem. I guess there is no way around looking at angles/slope in the way Zsban suggested. $\endgroup$ – Dave Dec 2 '14 at 3:25
-1
$\begingroup$

A non-trivial method can be to calculate the convex hull of the vertices. (This can only be used if the planar graph generated has a convex outer face, which is most likely the case for most of the graph drawing softwares.)

It seems to be an overkill though but it will give you the face exactly in form of a sequence of vertices given the coordinates of the vertices. It takes $O(n\log n)$ time to find it. You can use the standard LEDA library to find it easily using its subroutine.

However it can also be performed in linear time. Please refer to this.

$\endgroup$
  • $\begingroup$ Yes, convex hull was my go-to solution. The problem is that in addition to having non-linear complexity (which would worsen the overall complexity of what I am trying to do), it depends on the "niceness" of the graph drawing algorithm: a plane graph could perfectly have concave angles on its outer boundary. Inspired by some other contributions, I have figured a solution that is a bit more straightforward (and definitely O(n)). I will post it and maybe someone can improve it or critique it. $\endgroup$ – Dave Nov 27 '14 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.