99
Breadth-first search
The full graph could look something like this.
Alex owes Rama money, Tom owes Adit money, and so on. Each graph
is made up of
nodes
and
edges
.
That’s all there is to it! Graphs are made up of nodes and edges. A node
can be directly connected to many other nodes. Those nodes are called
its
neighbors
. In this graph, Rama is Alex’s neighbor. Adit isn’t Alex’s
neighbor, because they aren’t directly connected. But Adit is Rama’s and
Tom’s neighbor.
Graphs are a way to model how different things are connected to one
another. Now let’s see breadth-first search in action.
Dostları ilə paylaş: