We will be implementing Directed Graph (Digraph) with Adjacency List. Also I will be using some ECMA2015+ syntax, which should not be difficult to understand.
constructor we create a new instance of Map object and we call it
Most people know the concept of shallow copy, but they come across deep copy less often. Let’s start by defining what these two terms mean:
Before we talk about shallow copy, let’s quickly talk about reference to an object. Let’s use a simple example by declaring a variable that holds values for a one dimensional array.
const array1 = [1, 2, 3, 4, 5, 6, 7, 8]
And then we try to “copy” it to another variable.
const array2 = array1;