using
System;
class
GFG{
static
readonly
int
X = 6;
static
readonly
int
Z = 2;
static
bool
existPath(
int
V,
int
[,]edges,
int
u,
int
v)
{
bool
[,]mat =
new
bool
[V, V];
for
(
int
i = 0; i < X; i++)
mat[edges[i, 0], edges[i, 1]] =
true
;
for
(
int
k = 0; k < V; k++)
{
for
(
int
i = 0; i < V; i++)
{
for
(
int
j = 0; j < V; j++)
{
mat[i, j] = mat[i, j] ||
mat[i, k] &&
mat[k, j];
}
}
}
if
(u >= V || v >= V)
{
return
false
;
}
if
(mat[u, v])
return
true
;
return
false
;
}
public
static
void
Main(String[] args)
{
int
V = 4;
int
[,]edges = { { 0, 2 }, { 0, 1 },
{ 1, 2 }, { 2, 3 },
{ 2, 0 }, { 3, 3 } };
int
u = 1, v = 3;
if
(existPath(V, edges, u, v))
Console.Write(
"Yes\n"
);
else
Console.Write(
"No\n"
);
}
}