Depth First Search (Adjacency List) in JavaScript
Use object literals

Your code currently refers to the graph object about 15 times. This is unnecessary, as the graph object is simply the eventual output of makeGraphs.

So, instead of creating the empty object graph and adding properties and methods later, you can use a single object literal declaration. Using an object literal allows you to abbreviate initialization of object properties and functions.

Where you have:

    let graph = {};


Replace with:

    return {


Then, all subsequent references to graph can then be removed altogether, or, in rare cases where required, replaced with this. Object literals also clean up the look of your other objects, such as edges and nodes.

For example, your addVertex function would look like this:

    addVertex(node) {
        this[node] = {
            edges: {},
            isVisited: false,
            value: node,
        } 
    }


(Note: The arrow operator is not needed because the scope is determined by the object container.)

Handle creating edges / vertices from an array:

The part at the bottom shows how cumbersome it is to add edges and vertices one-by-one. The user would either have to write a loop or a container function. Instead, addEdge and addVertex could be easily modified to take array input. For example:

    addVertex(nodes) {
        for (var node in nodes) {
            this[node]: {
                edges: {},
                isVisited: false,
                value: node,
            }
        } 
    }


Then, to add vertices using addVertex:

dfsGraph.addVertex([1,2,3,4,5])