teach-ict.com logo

THE education site for computer science and ICT

1. Introduction to Graph

Before you read this section you should understand what are the queue and stack data structures as graphs make use of them. We have a section on queue and stack HERE.

A graph is a very useful dynamic data structure for modeling connections or relationships between items. A graph is dynamic because it can grow and shrink at runtime.

A basic graph looks like this:

Each connected item or node in a graph is called a vertex and each line connecting two vertices is called an edge. You can even have a vertex connecting to itself to form a cycle or loop, as shown in 'E'.

Each vertex has a 'degree', which describes how many connections that vertex has. For example 'B' is degree 3, 'A' is degree 1