Skip to main content

Driver program to perform operations in graph

Driver program to perform operations in graph:-



package com.problems.graph;

public class GraphDriver {

 public static void main(String[] args)
 {
  BFSGraph g=new BFSGraph();
  g.addVertex('A');
  g.addVertex('B');
  g.addVertex('C');
  g.addVertex('D');
  g.addVertex('E');
  g.addVertex('F');
  g.addVertex('G');
  g.addVertex('H');
 
  g.addEdge(0, 1);
  g.addEdge(1, 2);
  g.addEdge(1, 7);
  g.addEdge(2, 3);
  g.addEdge(2, 4);
  g.addEdge(7, 4);
  g.addEdge(4, 5);
  g.addEdge(4, 6);
  g.bfs();
 }
 
}

Comments

.

Popular posts from this blog

Best LeetCode Lists for Interviews

Here is a list of some of the best questions asked in interviews Must do Top interview questions Top 100 liked Must do 75  Must do 60  Must do medium Data structures Tree Graph  Dynamic Programming Company Interviews FaceBook interviews Amazon Interviews Google Interviews Github master List

Difference between Abstract Class and Interface

Difference between Abstract Class and Interface Difference between abstract class and interface ? Abstract Class:- 1) Can have abstract and non-abstract method both. 2) One class can extend at most one class. 3) can declare non abstract method and also can define body for it. Interface:- 1) can have only abstract method. 2) One class can implement multiple interfaces. 3) can't delare body to a method. Please look below example for more understanding:- package Basics ; public abstract class Animal { int head ; //no body (unimplemented function need to override in child class as a //compulsion abstract void setLegs (); //having body //may override or may not void setHead () { head =1; } } package Basics ; // can have only methods and by default all are abstract need to be override //by implementing class, unlike abstract no method can havedefinition public interface Pet { void tellWhereAreYouFr...