From the course: Python Data Structures and Algorithms

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Represent a maze as a 2D list

Represent a maze as a 2D list

- [Instructor] Many of the algorithms associated with pathfinding work with graphs. By graphs, I mean the sort associated with graph theory and mathematics, rather than in the sense of graphs and charts that you may be more familiar with. We will see in this video that a maze stored in a 2D list can represent a special type of graph where each cell in the list corresponds to a node and adjacent cells are connected by edges. So this is a very quick crash course in graphs, if you haven't come across them before. So basically we have nodes and edges. And in this image on the slide, you can see we're using letters to represent the nodes. And they're connected by edges, which are the green lines. Now there are different types of graph you can get, directed and undirected. So a directed graph is one where the direction between the nodes matters and undirected is where it doesn't matter. Also, you can have weighted graphs where each of the edges can have a different weight. Now, in our…

Contents