...

>

Directed and Undirected Graphs

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.

g a a b b a->b c c a->c b->c c->b
A graph with three nodes and four edges.

The above graph consists of three nodes (named aa, bb, cc) 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:

  • aba \to b
  • aca \to c
  • bcb \to c
  • cbc \to b

The actual positioning of the nodes in the graph does not matter. In other words, it has no significance that in the above drawing aa is “above” bb. In fact, here is the same graph drawn in a different layout:

g a a b b a->b c c a->c b->c c->b
The same graph as above, just drawn differently.

In other words, a graph is completely described by its set of nodes and edges.

By convention, the capital letter VV (for vertices) is used to denote the set of nodes. In our example graph, we have

V={a,b,c}.V = \{a, b, c\}. ...