Directed and Undirected Graphs
Learn about the difference between directed and undirected graphs.
Before we start diving into graph algorithms, let’s introduce some of the basic concepts of graph theory that we’ll use throughout the course.
Directed graphs
We’ll start with the most basic question: what even is a graph? Let’s look at an example.
The above graph consists of three nodes (named , , ) and four edges (drawn as arrows between nodes). The edges have a direction, indicated by the arrowhead. Hence, we call such a graph a directed graph:
The actual positioning of the nodes in the graph does not matter. In other words, it has no significance that in the above drawing is “above” . In fact, here is the same graph drawn in a different layout:
In other words, a graph is completely described by its set of nodes and edges.
By convention, the capital letter (for vertices) is used to denote the set of nodes. In our example graph, we have
...