Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

Directed & Undirected Graphs

Graphs are data structures used to represent data items which have connections between them, such as locations on a map or products on an e-commerce website.

Graphs

Graphs

  • Graphs consist of ‘nodes’ or ‘vertices’ which are joined by ‘arcs’ or ‘edges’ and can either be directed or undirected.
  • A directed graph is one where the connections between the nodes only go in one direction (the arcs are represented as arrows).
  • In an undirected graph, the connections are two-way.
Graph traversal

Graph traversal

  • There are two methods of traversing a graph:
    • Depth-first.
    • Breadth-first.
Depth-first traversal

Depth-first traversal

  • Depth-first traversal involves travelling down one route as far as possible, before reversing and travelling as far down the next route as possible.
  • In the graph shown, depth-first traversal would involve visiting the nodes in the following order:
    • A, B, E, C, D, G, F
Breadth-first

Breadth-first

  • Breadth-first traversal involves visiting all the adjoining nodes for each node in turn.
  • In the graph shown, breadth-first traversal would involve visiting the nodes in the following order:
    • A, B, C, E, D, F, G
Jump to other topics
1

Components of a Computer

2

Software & Software Development

3

Exchanging Data

4

Data Types, Data Structures & Algorithms

5

Legal, Moral, Cultural & Ethical Issues

6

Elements of Computational Thinking

6.1

Thinking Abstractly

6.2

Thinking Ahead

6.3

Thinking Procedurally

6.4

Thinking Logically

6.5

Thinking Concurrently

7

Problem Solving & Programming

8

Algorithms

Practice questions on Graphs

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
  2. 2
  3. 3
Answer all questions on Graphs

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium