SlideShare a Scribd company logo
4
Most read
9
Most read
11
Most read
BREADTH FIRST SEARCH
(BFS)
PADA GRAPH
Algoritma dan Struktur
Data
Dr. Achmad Solichin,
S.Kom, M.T.I
GRAPH
V = {0, 1, 2, 3}
E = {(0,1), (0,2), (0,3), (1,2)}
G = {V, E}
Indirect Graph
GRAPH TERMINOLOGY
 Adjacency: A vertex is said to be adjacent to another vertex if
there is an edge connecting them. Vertices 2 and 3 are not
adjacent because there is no edge between them.
 Path: A sequence of edges that allows you to go from vertex A
to vertex B is called a path. 0-1, 1-2 and 0-2 are paths from
vertex 0 to vertex 2.
 Directed Graph: A graph in which an edge (u,v) doesn't
necessarily mean that there is an edge (v, u) as well. The
edges in such a graph are represented by arrows to show the
direction of the edge.
GRAPH REPRESENTATION
1. Adjacency Matrix 2. Adjacency List
BREADTH FIRST SEARCH (BFS)
ALGORITHM
The BFS algorithm works as follows:
1. Start by putting any one of the graph's vertices at the back of a
queue.
2. Take the front item of the queue and add it to the visited list.
3. Create a list of that vertex's adjacent nodes. Add the ones which
aren't in the visited list to the back of the queue.
4. Keep repeating steps 2 and 3 until the queue is empty.
STEP BY STEP BFS ALGORITHM – 1
We use an undirected graph with 5 vertices
STEP BY STEP BFS ALGORITHM – 2
We start from vertex 0, the BFS algorithm starts by
putting it in the Visited list and putting all its
adjacent vertices in the queue.
STEP BY STEP BFS ALGORITHM – 3
Next, we visit the element at the front of queue i.e. 1
and go to its adjacent nodes. Since 0 has already
been visited, we visit 2 instead.
STEP BY STEP BFS ALGORITHM – 4
Vertex 2 has an unvisited adjacent vertex in 4, so we
add that to the back of the queue and visit 3, which
is at the front of the queue.
STEP BY STEP BFS ALGORITHM – 5
Only 4 remains in the queue since the only adjacent
node of 3 i.e. 0 is already visited. We visit it.
Since the queue is empty, we have completed the Depth First Traversal of the graph
BFS PSEUDOCODE (RECURSIVE)
BFS IMPLEMENTATION IN
PROGRAMMING
C C++ Java
https://qrgo.page.link/x9Seghttps://qrgo.page.link/f5aH4https://qrgo.page.link/AZAnW
REFERENCES
 Slide “Graph: Pemahaman dan Konsep Dasar Graph – Algoritma dan
Struktur Data 3” by Moh. Sjukani (Universitas Budi Luhur)
 Slide “Graph Traversal (Penelusuran Graph) – Algoritma dan Struktur
Data 3” by Achmad Solichin (Universitas Budi Luhur)
 BFS Algorithm - https://www.programiz.com/dsa/graph-bfs
TERIMA KASIH
 Dr. Achmad Solichin, S.Kom., M.T.I.
 Fakultas Teknologi Informasi, Universitas Budi Luhur
 achmatim@gmail.com | Achmad.Solichin@budiluhur.ac.id
 http://achmatim.net

More Related Content

PPTX
Presentation 2
PPT
8.3 Slope And Y Intercept
PPTX
KEY
CPSC 125 Ch 5 Sec 1
PPT
Graphing Quadradic
PPT
2.2 slope
PPT
Ml lesson 4 5
Presentation 2
8.3 Slope And Y Intercept
CPSC 125 Ch 5 Sec 1
Graphing Quadradic
2.2 slope
Ml lesson 4 5

What's hot (19)

PPTX
Finding the slope of a line
PDF
Slope of a line
PDF
Linear functions
PDF
Graph applications chapter
DOCX
Student U Slopes Handout
PPTX
Stair on slope of a line
PPT
6 4 Point Slope Form
PPTX
Bab 9 garis lurus (9.1.3)
PPT
Introduction to slope presentation
PPTX
Bab 9 garis lurus (9.1.6)
PPT
Review Of Slope And The Slope Intercept Formula
PPT
5.5 parallel perp lines
PPTX
Slope power point grade 8
PPT
Geo 3.6&7 slope
PPTX
Bab 9 garis lurus (9.1.1)
PPTX
January 15, 2015
PPTX
Graphing a line using Slope-Intercept form
PPT
Presentation on graphs
PDF
CombinatorialModels_Poster2016 (2)
Finding the slope of a line
Slope of a line
Linear functions
Graph applications chapter
Student U Slopes Handout
Stair on slope of a line
6 4 Point Slope Form
Bab 9 garis lurus (9.1.3)
Introduction to slope presentation
Bab 9 garis lurus (9.1.6)
Review Of Slope And The Slope Intercept Formula
5.5 parallel perp lines
Slope power point grade 8
Geo 3.6&7 slope
Bab 9 garis lurus (9.1.1)
January 15, 2015
Graphing a line using Slope-Intercept form
Presentation on graphs
CombinatorialModels_Poster2016 (2)
Ad

Similar to Breadth First Search (BFS) pada Graph (20)

PPTX
Depth First Search (DFS) pada Graph
PDF
Graph Theory
PPTX
Topological Sort and BFS
PPTX
WEB DEVELOPMET FRONT END WITH ADVANCED RECEAT
PPTX
Data structure Graph PPT ( BFS & DFS ) NOTES
PPTX
bfs tree searching ,sortingUntitled presentation.pptx
PPTX
logic.pptx
PDF
Daa chpater 12
PPTX
Representation of graph.pptx
PPTX
DATA STRUCTURES.pptx
PPTX
PPT
Graphs.pptGraphs.pptGraphs.pptGraphs.pptGraphs.pptGraphs.ppt
PPTX
UNIT III.pptx
PPT
Data Structures-Non Linear DataStructures-Graphs
PPT
Graphs
PPTX
Breadth-First-Search algorithm with Code
PPTX
Data structure note
PPTX
UNIT IV NON LINEAR DATA STRUCTURES - GRAPH.pptx
PDF
Class01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdf
Depth First Search (DFS) pada Graph
Graph Theory
Topological Sort and BFS
WEB DEVELOPMET FRONT END WITH ADVANCED RECEAT
Data structure Graph PPT ( BFS & DFS ) NOTES
bfs tree searching ,sortingUntitled presentation.pptx
logic.pptx
Daa chpater 12
Representation of graph.pptx
DATA STRUCTURES.pptx
Graphs.pptGraphs.pptGraphs.pptGraphs.pptGraphs.pptGraphs.ppt
UNIT III.pptx
Data Structures-Non Linear DataStructures-Graphs
Graphs
Breadth-First-Search algorithm with Code
Data structure note
UNIT IV NON LINEAR DATA STRUCTURES - GRAPH.pptx
Class01_Computer_Contest_Level_3_Notes_Sep_07 - Copy.pdf
Ad

More from Achmad Solichin (20)

PDF
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
PDF
Materi Webinar Web 3.0 (16 Juli 2022)
PDF
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
PPTX
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
PDF
Webinar PHP-ID: Machine Learning dengan PHP
PPTX
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
PPTX
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
PPTX
Metodologi Riset: Literature Review
PPTX
Materi Seminar: Artificial Intelligence dengan PHP
PPTX
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
PDF
Metodologi Riset: Literature Review
PPTX
Binary Search Tree (BST) - Algoritma dan Struktur Data
PPTX
Computer Vision di Era Industri 4.0
PDF
Seminar: Become a Reliable Web Programmer
PPTX
The Big 5: Future IT Trends
PDF
Modern PHP Developer
PPTX
Seminar: PHP Developer for Dummies
PPT
Pertemuan 1 - Algoritma dan Struktur Data 1
PPTX
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
PDF
Seminar: Mau jadi Android User atau Developer?
Kuliah Umum - Tips Publikasi Jurnal SINTA untuk Mahasiswa Galau (6 Agustus 2022)
Materi Webinar Web 3.0 (16 Juli 2022)
Webinar: Kesadaran Keamanan Informasi (3 Desember 2021)
Webinar PHP-ID: Mari Mengenal Logika Fuzzy (Fuzzy Logic)
Webinar PHP-ID: Machine Learning dengan PHP
Webinar Data Mining dengan Rapidminer | Universitas Budi Luhur
TREN DAN IDE RISET BIDANG DATA MINING TERBARU
Metodologi Riset: Literature Review
Materi Seminar: Artificial Intelligence dengan PHP
Percobaan Perpindahan Kalor melalui Konduksi, Konveksi dan Radiasi
Metodologi Riset: Literature Review
Binary Search Tree (BST) - Algoritma dan Struktur Data
Computer Vision di Era Industri 4.0
Seminar: Become a Reliable Web Programmer
The Big 5: Future IT Trends
Modern PHP Developer
Seminar: PHP Developer for Dummies
Pertemuan 1 - Algoritma dan Struktur Data 1
Sharing Penelitian S3 Lab Elins FMIPA UGM - 17 Februari 2016
Seminar: Mau jadi Android User atau Developer?

Recently uploaded (20)

PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Structure & Organelles in detailed.
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Lesson notes of climatology university.
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPH.pptx obstetrics and gynecology in nursing
102 student loan defaulters named and shamed – Is someone you know on the list?
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Insiders guide to clinical Medicine.pdf
VCE English Exam - Section C Student Revision Booklet
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Supply Chain Operations Speaking Notes -ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
Pharma ospi slides which help in ospi learning
Cell Structure & Organelles in detailed.
Complications of Minimal Access Surgery at WLH
Lesson notes of climatology university.
01-Introduction-to-Information-Management.pdf
Microbial diseases, their pathogenesis and prophylaxis

Breadth First Search (BFS) pada Graph

  • 1. BREADTH FIRST SEARCH (BFS) PADA GRAPH Algoritma dan Struktur Data Dr. Achmad Solichin, S.Kom, M.T.I
  • 2. GRAPH V = {0, 1, 2, 3} E = {(0,1), (0,2), (0,3), (1,2)} G = {V, E} Indirect Graph
  • 3. GRAPH TERMINOLOGY  Adjacency: A vertex is said to be adjacent to another vertex if there is an edge connecting them. Vertices 2 and 3 are not adjacent because there is no edge between them.  Path: A sequence of edges that allows you to go from vertex A to vertex B is called a path. 0-1, 1-2 and 0-2 are paths from vertex 0 to vertex 2.  Directed Graph: A graph in which an edge (u,v) doesn't necessarily mean that there is an edge (v, u) as well. The edges in such a graph are represented by arrows to show the direction of the edge.
  • 4. GRAPH REPRESENTATION 1. Adjacency Matrix 2. Adjacency List
  • 5. BREADTH FIRST SEARCH (BFS) ALGORITHM The BFS algorithm works as follows: 1. Start by putting any one of the graph's vertices at the back of a queue. 2. Take the front item of the queue and add it to the visited list. 3. Create a list of that vertex's adjacent nodes. Add the ones which aren't in the visited list to the back of the queue. 4. Keep repeating steps 2 and 3 until the queue is empty.
  • 6. STEP BY STEP BFS ALGORITHM – 1 We use an undirected graph with 5 vertices
  • 7. STEP BY STEP BFS ALGORITHM – 2 We start from vertex 0, the BFS algorithm starts by putting it in the Visited list and putting all its adjacent vertices in the queue.
  • 8. STEP BY STEP BFS ALGORITHM – 3 Next, we visit the element at the front of queue i.e. 1 and go to its adjacent nodes. Since 0 has already been visited, we visit 2 instead.
  • 9. STEP BY STEP BFS ALGORITHM – 4 Vertex 2 has an unvisited adjacent vertex in 4, so we add that to the back of the queue and visit 3, which is at the front of the queue.
  • 10. STEP BY STEP BFS ALGORITHM – 5 Only 4 remains in the queue since the only adjacent node of 3 i.e. 0 is already visited. We visit it. Since the queue is empty, we have completed the Depth First Traversal of the graph
  • 12. BFS IMPLEMENTATION IN PROGRAMMING C C++ Java https://qrgo.page.link/x9Seghttps://qrgo.page.link/f5aH4https://qrgo.page.link/AZAnW
  • 13. REFERENCES  Slide “Graph: Pemahaman dan Konsep Dasar Graph – Algoritma dan Struktur Data 3” by Moh. Sjukani (Universitas Budi Luhur)  Slide “Graph Traversal (Penelusuran Graph) – Algoritma dan Struktur Data 3” by Achmad Solichin (Universitas Budi Luhur)  BFS Algorithm - https://www.programiz.com/dsa/graph-bfs
  • 14. TERIMA KASIH  Dr. Achmad Solichin, S.Kom., M.T.I.  Fakultas Teknologi Informasi, Universitas Budi Luhur  achmatim@gmail.com | Achmad.Solichin@budiluhur.ac.id  http://achmatim.net