Two graph algorithms every developer should know!

From It Takes Two Neurons To Ride a Bicycle

In the age of data, graph traversal algorithms are some of the most applicable tools for software engineers. Graph traversal is the process of finding some path in a network, or just exploring the network in a particular way. There are dozens of algorithms and strategies for graph traversal — breadth first search (BFS) and depth first search (DFS) prove to be simple yet highly effective algorithms for approaching graph problems.

In this article, we will learn to understand the two algorithms in addition to implementing them in my favorite programming language — Go.

## Understand the Algorithms

Before we get to any code, it’s always a good first step to understand the problem. Drawing out visualizations, working through examples and reiterating the problem to yourself are great ways to incrementally solve the problem.

Made with LucidChart

Starting with the fundamentals, a graph network can be arranged in an infinite number of sizes and configurations. This article will focus on graphs in a tree format, where there is one root node with many children nodes.

Any sub-node is designated as a child node, with the node it stemmed one being labeled its parent node.

Each level of a tree is determined by the depth of the children hierarchy. This should be more than enough information you need to understand graphs for the context of this article.

Now, onto the algorithms!

#golang #programming #technology