isConnected

Class: triangulation

Test if two vertices are connected by edge

Syntax

tf = isConnected(TR,vstart,vend)
tf = isConnected(TR,E)

Description

tf = isConnected(TR,vstart,vend) returns a logical array of true or false values that indicate whether the specified pairs of vertices are connected by an edge. Element tf(j) is true when the vertices, vstart(j) and vend(j), are connected by an edge.

tf = isConnected(TR,E) specifies the edge start and end indices in matrix E. Element tf(j) is true when the vertices, E(j,1) and E(j,2), are connected by an edge.

Input Arguments

TR

Triangulation representation, see triangulation or delaunayTriangulation.

vstart

IDs of start vertices, specified as a column vector. Each vertex ID refers to a vertex at the start of an edge.

vend

IDs of end vertices, specified as a column vector. Each vertex ID refers to a vertex at the end of an edge.

E

IDs of the edge vertices, specified as a two-column matrix. Each row of E corresponds to a candidate edge and contains two IDs:

  • E(j,1) is the ID of the vertex at the start of a candidate edge.

  • E(j,2) is the ID of the vertex at end of the edge.

Output Arguments

tf

Logical values, returned as a column vector. Element tf(j) is true when either of the following are true:

  • The vertices, vstart(j) and vend(j), are connected by an edge.

  • The vertices, E(j,1) and E(j,2), are connected by an edge.

Otherwise, tf(j) is false.

Definitions

Vertex ID

A row number of the matrix, TR.Points. Use this ID to refer a specific vertex in the triangulation.

Examples

expand all

Determine Whether Vertices are connected by an Edge in 2-D

Load a 2-D triangulation.

load trimesh2d
TR = triangulation(tri,x,y);

Determine whether vertices 3 and 117 are connected by an edge.

isConnected(TR,3,117)
ans =

     1

The vertices are connected by an edge.

Determine whether vertices 3 and 164 are connected by an edge.

isConnected(TR,3,164)
ans =

     0

The vertices are not connected by an edge.

Determine Whether Vertices are connected by an Edge in 3-D

X = gallery('uniformdata',[10,3],0);
DT = delaunayTriangulation(X);

Determine whether vertices 2 and 7 are connected by an edge.

E = [2 7];
isConnected(DT,E)
ans =

     1

The vertices are connected by an edge.

Was this topic helpful?