You are on page 1of 2

using

using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace OOP_Lecture_SE_M
{
class graph
{
int[,] mat=new int[3,3];
int[] degree = new int[3];
public void getvalues()
{
Console.WriteLine("Enter values for indexes given below");
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
{
Console.Write(i + " " + j+"
");
mat[i, j] = Convert.ToInt32(Console.ReadLine());
// Console.WriteLine("Value for " + i + " " + j + " is " + ma
t[i, j]);
}
}
public void caldegree()
{
int count = 0;
for (int i = 0; i < 3; i++)
{
count = 0;
for (int j = 0; j < 3; j++)
{
if (mat[i, j] == 1)
count = count + 1;
}
degree[i] = count;
}
}
public void viewdeg()
{
Console.WriteLine("Degree is ");
foreach (int a in degree)
Console.WriteLine(a);
}
int read()
{
int a =Convert.ToInt32( Console.ReadLine());
return a;
}
public void viewgraph()
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
Console.Write(this.mat[i, j]+"\t");
Console.WriteLine();
}
}

public int menu()


{
Console.WriteLine("Enter your choice ");
Console.WriteLine("1: Insert a graph");
Console.WriteLine("2: View degre");
Console.WriteLine("3: Update a graph");
Console.WriteLine("4: View graph");
Console.WriteLine("5: Convert to adjacency list");
Console.WriteLine("6: Exit");
int choice = read();
return choice;
}
public void takedecision(int c)
{
switch (c)
{
case 1:
getvalues();
break;
case 2:
caldegree();
viewdeg();
break;
case 3:
Console.WriteLine("Under construction");
break;
case 4:
viewgraph();
break;
case 5:
Console.WriteLine("Under construction");
break;
case 6:
Console.WriteLine("Press any key to exit");
break;
}
}
}
class Program
{
static void Main(string[] args)
{
graph g = new graph();
do
{
Console.Clear();
int ch = g.menu();
g.takedecision(ch);
Console.WriteLine("Press y for main menu");
char c = Convert.ToChar(Console.ReadLine());
if (c != 'y')
break;
}
while (true);
}
}
}

You might also like