Use cases
Implementing a graph is similar to that of trees; there is no set way of creating one. However, based on your use case, you can structure your graphs as directed, cyclic, or any other form as explained earlier. Doing this can make their traversal easier, which would, in turn, make data retrieval easier and faster.
Let's take a look at some examples for which we will be needing a base application first.
Creating a Node.js web server
Let's first create a web server using Node.js, which we will use to create endpoints later on to access our graph-based applications:
- The first step is to create your application's project folder; to do so, run the following command from the Terminal:
mkdir <project-name>
- Then, to initialize a Node.js project, run the
init
command in the root folder of your project. This will prompt a series of questions to generate thepackage.json
file. You can fill out the answers you want or just click onreturn
to accept default values for the prompts:
...