How to Implement Breadth-First Search in Python

Breadth-first search (BFS) is an algorithm used for traversing graph data structures. In other words,  BFS implements a specific strategy for visiting all the nodes (vertices) of a graph – more on graphs in a while. What is this exploration strategy? It’s very simple and effective. BFS starts with a node, then it checks the neighbours of the initial node, then the neighbours of the neighbours, and so on. In case you didn’t recall it, two vertices are ‘neighbours’ if they are connected with an edge.

Continue reading “How to Implement Breadth-First Search in Python”

How to Do Socket Programming in Python

This article provides a brief tutorial on how to code sockets in Python. Socket programming can be a bit confusing at first, but, fortunately for us, Python makes it really easy.

I assume that you already have a basic understanding of Python. You can download the code for this tutorial from this GitHub repository.

Before plunging into implementation, let’s review a bit of theory first to acquire basic notions about sockets.

Continue reading “How to Do Socket Programming in Python”