Discrete Graphs: Detailed Examples

Zachary Aug 05, 2026

Discrete graphs, a fundamental concept in graph theory, are mathematical structures consisting of nodes (or vertices) and edges connecting them. They are used to model relationships in computer science, mathematics, and real-life problems. Let's delve into an example and explore their key properties.

What Is the Difference Between a Directed and an Undirected Graph | Baeldung on Computer Science
What Is the Difference Between a Directed and an Undirected Graph | Baeldung on Computer Science

Consider an example of a discrete graph: a social network, such as a group of friends on a messaging app. Each friend is a node, and if two friends are connected (they are friends with each other), there's an edge between their nodes.

the different types of graphs are shown in this diagram, and there is also an info sheet
the different types of graphs are shown in this diagram, and there is also an info sheet

Graph Representation

Graphs can be represented in different ways. For discrete graphs, we typically use either an adjacency matrix or an adjacency list.

Directed Vs Undirected Graph
Directed Vs Undirected Graph

A simple undirected graph with 6 nodes and edges between them can be represented by an adjacency matrix like this:

123456
1010100
2101010
3010101
4101010
5010101
6001010
Line Graph Worksheets
Line Graph Worksheets

Undirected vs Directed Graphs

In undirected graphs, edges don't have a direction. In our social network example, if Alice is friends with Bob, Bob is also friends with Alice. However, in a directed graph, edges have a direction, making the relationship asymmetric.

A real-world example of a directed graph is following relationships on Twitter. If Alice follows Bob, Bob might not follow Alice back. Here's an adjacency list representation:

four squares with dots in the middle and one line on each side that shows different types of
four squares with dots in the middle and one line on each side that shows different types of
  • 1: [2, 4]
  • 2: [1, 3, 5]
  • 3: [2, 4, 6]
  • 4: [1, 3]
  • 5: [2, 4, 6]
  • 6: [3, 5]

Weighted vs Unweighted Graphs

Weighted graphs have edges with assigned values, representing the strength or cost of the connection. Unweighted graphs, like the ones we've seen so far, have edges without values.

Basic Graph Types ( Read ) | Statistics
Basic Graph Types ( Read ) | Statistics

Consider a delivery company mapping out routes for its drivers. The graph could be weighted according to the distance between cities. Here's a weighted adjacency matrix:

123456
1030200
Graph Worksheets | Learning to Work with Charts and Graphs
Graph Worksheets | Learning to Work with Charts and Graphs
Reading and Interpreting a Line Graphs
Reading and Interpreting a Line Graphs
MA2-Wednesday Reading a line graph worksheet
MA2-Wednesday Reading a line graph worksheet
Line Graphing Practice
Line Graphing Practice
Normal Distribution vs t-Distribution 📈 | Key Differences Explained
Normal Distribution vs t-Distribution 📈 | Key Differences Explained
an info sheet with graphs and diagrams on it
an info sheet with graphs and diagrams on it
Scatter Diagram
Scatter Diagram
a line graph with the number of active daily players
a line graph with the number of active daily players
Read Line Graph Worksheet For Grade 2
Read Line Graph Worksheet For Grade 2
the types of graphs that you can use to help students understand what they are doing
the types of graphs that you can use to help students understand what they are doing

Graph Traversal

Graph traversal involves visiting each node in a graph in a specific order. Two common methods are Depth-First Search (DFS) and Breadth-First Search (BFS).

In our social network example, if you wanted to find a friend of a friend (traverse the graph), DFS and BFS would take different routes but eventually cover all nodes.

Depth-First Search (DFS)

DFS starts from a source node and explores as far as possible along each branch before backtracking. It's suitable for finding paths or cycles in a graph. Using the directed, weighted graph:

  • Start at node 1.
  • Visit node 2 (weight = 3), then node 5 (weight = 2), then node 6 (weight = 1).
  • Backtrack to node 2, then visit node 3 (weight = 1), and finally, node 4 (weight = 2).

Breadth-First Search (BFS)

BFS visits all nodes at the present depth level before going to nodes at the next depth level. It's useful for finding the shortest path between two nodes in an unweighted graph. For our social network:

  • Start at node 1.
  • Visit nodes 2 and 4 at depth 1.
  • Visit node 3 at depth 2, then visit nodes 5 and 6 at depth 3.

Discrete graphs are versatile tools for modeling and understanding complex systems. By exploring different representations, properties, and traversal methods, we gain insights into their power and flexibility.