Let’s learn about graphs in Go.


A graph is a data structure that represents a network. It is made up of vertices (also called nodes) and edges, which are the connections between vertices. There are two types of edges: directed and undirected. A directed edge allows us to go only in one direction, but an undirected edge allows us to go in both directions. There can be a cost associated with the edges.

There are several algorithms that we commonly use to traverse a graph. We’ll discuss two transversal algorithms of graphs: Depth-first search (DFS) and breadth-first search (BFS).

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.