What is the difference between a directed and undirected graph

It means exactly what it sounds like. In a directed graph, direction matters. i.e. edge 2->3 means that edge is directed. There is only an edge from 2 to 3 and no edge from 3 to 2. Therefore you can go from vertex 2 to vertex 3 but not from 3 to 2.

In undirected graph 2-3 means the edge has no direction, i.e. 2-3 means you can go both from 2 to 3 and 3 to 2.

Note that in the representation of your graph, if you are using an adjacency matrix, directed 2->3 means adj[2][3]=true but adj[3][2]=false. In undirected it means adj[2][3]=adj[3][2]=true.


The difference is the same as between one directional and bidirectional streets - in directed graph, the direction matters and you can't use the edge in the other direction. An undirected graph can be simulated using a directed graph by using pairs of edges in both directions.