Advertisement
vencinachev

GraphMatrixMain

Sep 10th, 2019
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             Console.Write("Enter node to start: ");
  6.             int start = int.Parse(Console.ReadLine());
  7.  
  8.             int[,] graph = new int[,] { { 0, 1, 1, 1, 1 },
  9.                                       { 1, 0, 0, 0, 1 },
  10.                                       { 1, 0, 0, 1, 1 },
  11.                                       { 1, 0, 1, 0, 0 },
  12.                                       { 1, 1, 1, 0, 0 } };
  13.  
  14.             GraphMatrix gm = new GraphMatrix(graph);
  15.  
  16.             try
  17.             {
  18.                 Console.Write($"BFS from node {start}: ");
  19.                 gm.PrintBFS(start);
  20.                 Console.WriteLine();
  21.                 Console.Write($"DFS drom node {start}: ");
  22.                 gm.PrintDFS(start);
  23.             }
  24.             catch (ArgumentException e)
  25.             {
  26.                 Console.WriteLine(e.Message);
  27.             }
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement