How to define condition for spliting vertices on corner and non-corner vertices?

60 Views Asked by At

I have an undirected graph with $n<100$ vertices. The graph is simple. The coordinates of all vertices are known and fixed $(x_i, y_i) \in \mathbf{Z}$, $i=1, 2,\ldots, n$, the set of edges is predefinded, they are line segments with the length $1$ unit. The degree of vertices can be $2$, $3$ or $4$.

On the sketch below vertices $4$ and $5$ have degree $3$, while the remaining vertices have degree $2$.

Question. How can to split the set of all vertices with the degree equals to $2$ into two sets? The first set should includes the corner vertices $\{1, 3, 6, 8\}$, and the second set should includes the non-corner vertices $\{2, 7, 9\}$.

Edit.

enter image description here

My attempt. Let the vertex $i$ be the corner vertex if its degree is $2$ and two incident edges do not lie on the same line.

We can select the $i$ vertex with degree $2$ and compute the angle $\alpha$ between the two incident edges $e_1$ and $e_2$, if $\alpha == 180$ then we can say that $i$-th vertex is the non-corner vertex, else it is the corner vertex.

1

There are 1 best solutions below

0
On

You don't need to calculate the angle. You look only at the coordinates of the neighbours. If both have the same x- or y-coordinate, it is a non-corner node. Else it is a corner node.