01-Toturial Week2
01-Toturial Week2
Week 2
Liang QU
School of EECS
The University of Queensland
About me: Liang QU
• About INFS7450
• Graph Essentials
• Coding Demo
• Q&A
Section 1: Recall Key Points on INFS7450
Section 1: Course Schedule
Section 1: Course Website - Blackboard
Examples of misuse:
• Reports: Submitting a report generated by AI without indicating that AI was used.
• Code: Incorporating AI-generated code in your projects without citing the AI as a source.
• Quizzes: Using AI to answer quiz questions
Directed Undirected
Section 2: Types of Graphs
• Weighted graph VS unweighted graph
– Degree has generally been extended to the sum of weights when analyzing
weighted graph.
Section 2: Types of Graphs
• Regular graph VS complete graph
– A regular graph is a graph where each node has the same number of
neighbors; i.e., every node has the same degree.
– A complete graph is a graph in which each pair of graph nodes is connected
by an edge.
– A complete graph is always a regular graph.
1 6
0 2
4
7
3
5
Section 2: DFS
1 6
0 2
4
7
3
5
Section 2: DFS
0 2
4
7
3
5
1 6
0 2
4
7
3
5
1 6
0 2
4
7
3
5
1 6
0 2
4
7
3
5
1 6
0 2
4
7
3
5
2
1 6
0 2
4
7
3
5
2
1 6
0 2
4
7
4 3
5
2
1 6
0 2
4
7
4 3
5
2
1 6
0 2
6 4
7
4 3
5
2
1 6
7
0 2
6 4
7
4 3
5
2
5
1 6
7
0 2
6 4
7
4 3
5
2
5
1 6
7
0 2
6 4
7
4 3
5
2
5
1 6
7
0 2
6 4
7
4 3
5
2
5
1 6
7
0 2
6 4
7
4 3
5
2
5
1 6
7
0 2
6 4
7
4 3
5
2
5
1 6
7
0 2
6 4
7
4 3
5
2
5
1 6
7
0 2
6 4
7
4 3
5
2
7
5
1 6
7
0 2
6 4
7
4 3
5
2
1 6
0 2
4
7
3
5
Section 2: Breadth First Search (BFS)
0 2
4
7
3
5
Section 2: Breadth First Search (BFS)
0 2
4
7
3
5
Section 2: Breadth First Search (BFS)
0 2
4
7
3
5
Section 2: Breadth First Search (BFS)
0 2
4
7
3
5
Section 2: Breadth First Search (BFS)
0 2
4
7
3
5
Section 2: Using a Queue
Queue Front
Section 2: Breadth First Search (BFS)
0 2
4
7
3
5
0
Section 2: Breadth First Search (BFS)
1 6
0 2
4
7
3
5
0
Section 2: Breadth First Search (BFS)
1 6
0 2
4
7
3
5
3
0
Section 2: Breadth First Search (BFS)
• After we add all the neighbor nodes of node 0 to the queue, we say that we
have visited the node 0.
• The node 0 will dequeue.
• We will visit the next node in the queue, i..e, the node 1
1 6
0 2
4
7
3
5
3
0
Section 2: Breadth First Search (BFS)
1 6
0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
• After we add all the neighbor nodes of node 1 to the queue, we say that we have
visited the node 1.
• The node 1 will dequeue.
• We will visit the next node in the queue, i..e, the node 3
• Here is the difference between DFS and BFS
1 6
0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
7
1 6
6
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
7
1 6
6
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
7
1 6
6
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
7
1 6
6
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
7
1 6
6
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)
7
1 6
6
4 0 2
4
7
2 3
5
3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
0 2 4
4
2 1
3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
0 2 4
4
2 1
3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
0 2 4
4
2 1
3 3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
0 2 4
4
2 1
3 3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
0 2 4
2 4
2 1
3 3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
0 2 4
2 4
2 1
3 3
Path: 0 -->3, Length: 2
1 Path: 0 -->1, Length: 3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
0 2 4
2 4
2 1
3 3
Path: 0 -->3, Length: 2
1 Path: 0 -->1, Length: 3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
0 2 4
Path: 0 à1à2, Length: 3+7=10
2 4
Path: 0 à3à2, Length:2+1=3
2 1
3 3
Path: 0 -->3, Length: 2
1 Path: 0 -->1, Length: 3
0
Section 2: Breadth First Search (BFS)-Application
3 1 7
4
0 2 4
Path: 0 à1à2, Length: 3+7=10
2 4
Path: 0 à3à2, Length:2+1=3
2 1
3 3
Path: 0 -->3, Length: 2
1 Path: 0 -->1, Length: 3
0
Section 2: Breadth First Search (BFS)-Application
0
Section 2: Breadth First Search (BFS)-Application
0
A: BFS
B: DFS