Creating Graphs With JavaScript
Graphs are a data structure comprised of a collection of nodes with edges. A graph can be directed or undirected.
A directed graph contains edges which function similar to a one-way street. The edge flows from one node to another.
For example, you might have a graph of people and movies where each person can have several favorite movies but movies do not have a favorite person.
An undirected graph contains edges which flow bi-directionally, similar to a two-lane road with traffic going in both directions.
For example, you might have a graph of pets where each pet has an owner and each owner has a pet. Note: The bi-directional arrows represent one edge, but for the sake of explicitness, I’ve drawn two arrows.
There is no clear hierarchy of information in a graph.
Methods
We’re going to build a graph of people and ice cream flavors. It will be a directed graph, as people can like certain flavors, but…