Graph Theory in Javascript

I’ve been a speaker to a London Algorithms Meetup and the subject was Graph Theory.

Here there is the link to the repository: https://github.com/LondonAlgorithms/graph_theory with the javascript code.

I have created a pairing exercise with specs to guide through the creation of an undirect Graph by using an adjacency list. After all the vertices and edges have been added to the Graph, the exercise requires to visit a Graph with a Breadth First Search Algorithm. In the repo I have written some Javascript tests to follow during the code development. You can run tests by opening SpecRunner.html.

In the repo there are two branches: master and solution.
As you might expect, solution branch contains the complete javascript code.

After a brief introduction to what is a Graph and which are the use cases, I’ve explained how to build a graph with an Adjacency List and then I’ve shown which are the Graph Traversal Algorithms: Depth First Search and Breadth First Search.

What is a Graph

Graph is a non linear data structure, it contains a set of points known as nodes (or vertices) and set of linkes known as edges (or Arcs) which connects the vertices.

Continue reading “Graph Theory in Javascript”