using
System;
class
GFG
{
static
int
M = 3;
static
int
N = 3;
static
Boolean bpm(
int
[,]table,
int
u,
Boolean []seen,
int
[]matchR)
{
for
(
int
v = 0; v < N; v++)
{
if
(table[u, v] > 0 && !seen[v])
{
seen[v] =
true
;
if
(matchR[v] < 0 || bpm(table, matchR[v],
seen, matchR))
{
matchR[v] = u;
return
true
;
}
}
}
return
false
;
}
static
int
maxBPM(
int
[,]table)
{
int
[]matchR =
new
int
[N];
for
(
int
i = 0; i < N; i++)
matchR[i] = -1;
int
result = 0;
for
(
int
u = 0; u < M; u++)
{
Boolean []seen =
new
Boolean[N];
if
(bpm(table, u, seen, matchR))
result++;
}
Console.WriteLine(
"The number of maximum packets"
+
" sent in the time slot is "
+ result);
for
(
int
x = 0; x < N; x++)
if
(matchR[x] + 1 != 0)
Console.WriteLine(
"T"
+ (matchR[x] + 1) +
"-> R"
+ (x + 1));
return
result;
}
public
static
void
Main(String[] args)
{
int
[,]table = {{0, 2, 0},
{3, 0, 1},
{2, 4, 0}};
maxBPM(table);
}
}