SlideShare a Scribd company logo
Graph – Basic concepts
Basic Concepts
A graph is an ordered pair (V, E).
V is the set of vertices. (You can think of them as integers 1,
2, …, n.)
E is the set of edges. An edge is a pair of vertices: (u, v).
Edges can be labeled with a weight:
6-Graphs
10
Concepts: Directedness
In a directed graph, the edges are “one-way.” So an edge (u, v)
means you can go from u to v, but not vice versa.
In an undirected graph, there is no direction on the edges: you can go
either way. (Also, no self-loops.)
6-Graphs
a self-loop
Concepts: Adjacency
Two vertices are adjacent if there is an edge between them.
For a directed graph, u is adjacent to v iff there is an edge (v, u).
6-Graphs
u w
v
u is adjacent to v.
v is adjacent to u and w.
w is adjacent to v.
u w
v
u is adjacent to v.
v is adjacent to w.
Concepts: Degree
Undirected graph: The degree of a vertex is the number of edges
touching it.
For a directed graph, the in-degree is the number of edges entering
the vertex, and the out-degree is the number leaving it. The degree is
the in-degree + the out-degree.
6-Graphs
degree 4
in-degree 2, out-degree 1
Concepts: Path
A path is a sequence of adjacent vertices. The length of a path is the
number of edges it contains, i.e. one less than the number of vertices.
We write u ⇒ v if there is path from u to v. We say v is reachable
from u.
6-Graphs
1
2
3
4
Is there a path from 1 to 4?
What is its length?
What about from 4 to 1?
How many paths are there from 2 to
3? From 2 to 2? From 1 to 1?
Concepts: Cycle
•A cycle is a path of length at least 1 from a vertex to itself.
•A graph with no cycles is acyclic.
•A path with no cycles is a simple path.
•The path <2, 3, 4, 2> is a cycle.
6-Graphs
1
2
3
4
Concepts: Connectedness
•An undirected graph is connected iff there is a path between any two
vertices.
•The adjacency graph of U.S. states has three connected components.
Name them.
•(We say a directed graph is strongly connected iff there is a path
between any two vertices.)
6-Graphs
An unconnected graph with three
connected components.
ADJACENCY MATRIX
REPRESENTATION
• 1 2 3 4
1 1 1 1 1
2 1 0 0 0
3 0 1 0 1
4 0 1 1 0
ADJACENCY LIST
REPRESENTATION
 1 -> 1 -> 2 -> 3 -> 4
2 -> 1
3 -> 2 -> 4
4 -> 2 -> 3
GUIDED READING
2.1 graph basic
ASSESSMENT
1. Which of the following statements is true?
A. A graph can drawn on paper in only one
way.
B. Graph vertices may be linked in any
manner.
C. A graph must have at least one vertex.
D. A graph must have at least one edge.

CONTD..
2. Suppose you have a game with 5 coins in
a row and each coin can be heads or tails.
What number of vertices might you expect to
find in the state graph?
A. 7
B. 10
C. 25
D. 32
CONTD..
3. Why is the state graph for tic-tac-toe a
directed graph rather than an undirected
graph?
A. Once a move is made, it cannot be
unmade.
B. There is an odd number of vertices.
C. There is an odd number of edges.
D. There is more than one player in the
game.
CONTD..
4. A simple graph has no loops. What other
property must a simple graph have?
A. It must be directed.
B. It must be undirected.
C. It must have at least one vertex.
D. It must have no multiple edges.
CONTD..
5. Suppose you have a directed graph
representing all the flights that an airline flies.
What algorithm might be used to find the best
sequence of connections from one city to
another?
A. Breadth first search.
B. Depth first search.
C. A cycle-finding algorithm.
D. A shortest-path algorithm.

More Related Content

What's hot (20)

PDF
Graph in Data Structure
Prof Ansari
 
PPTX
Graphs in data structure
hamza javed
 
PPTX
Adjacency list
Stefi Yu
 
PPTX
Graph Data Structure
Afaq Mansoor Khan
 
PPTX
Graph Theory
Rashmi Bhat
 
PPTX
Application Of Graph Data Structure
Gaurang Dobariya
 
PPTX
Graph data structure and algorithms
Anandhasilambarasan D
 
PPT
Data structure computer graphs
Kumar
 
PPTX
Graph in data structure
Abrish06
 
PPTX
Graph representation
Tech_MX
 
PPTX
Data Structure Graph DMZ #DMZone
Doug Needham
 
PPTX
Graphs data Structure
Mahmoud Alfarra
 
PPTX
Lecture 16 graph introduction
Abirami A
 
PPT
Graphs in c language
SARITHA REDDY
 
PPTX
Data structure - Graph
Madhu Bala
 
PPT
Graphs in data structures
Savit Chandra
 
PDF
Talk on Graph Theory - I
Anirudh Raja
 
PPTX
Graph (Data structure)
shamiur rahman
 
PPTX
Matrix representation of graph
Rounak Biswas
 
PDF
Skiena algorithm 2007 lecture10 graph data strctures
zukun
 
Graph in Data Structure
Prof Ansari
 
Graphs in data structure
hamza javed
 
Adjacency list
Stefi Yu
 
Graph Data Structure
Afaq Mansoor Khan
 
Graph Theory
Rashmi Bhat
 
Application Of Graph Data Structure
Gaurang Dobariya
 
Graph data structure and algorithms
Anandhasilambarasan D
 
Data structure computer graphs
Kumar
 
Graph in data structure
Abrish06
 
Graph representation
Tech_MX
 
Data Structure Graph DMZ #DMZone
Doug Needham
 
Graphs data Structure
Mahmoud Alfarra
 
Lecture 16 graph introduction
Abirami A
 
Graphs in c language
SARITHA REDDY
 
Data structure - Graph
Madhu Bala
 
Graphs in data structures
Savit Chandra
 
Talk on Graph Theory - I
Anirudh Raja
 
Graph (Data structure)
shamiur rahman
 
Matrix representation of graph
Rounak Biswas
 
Skiena algorithm 2007 lecture10 graph data strctures
zukun
 

Viewers also liked (20)

PPT
1.10.association mining 2
Krish_ver2
 
PDF
문제는 한글이 잘 구현되는가?
Choi Man Dream
 
DOCX
CV Belinda Wahl 2015
Belinda Wahl
 
PPT
5.2 divede and conquer 03
Krish_ver2
 
DOCX
nhận thiết kế clip quảng cáo giá tốt
raul110
 
PPTX
РЕКЛАМНЫЕ МОДЕЛИ
Moscow State University of Printing Arts
 
DOC
RESUME-ARITRA BHOWMIK
Aritra Bhowmik
 
PDF
160607 14 sw교육_강의안
Choi Man Dream
 
PPT
Online Trading Concepts
Fxmoneyworld LTD
 
PPT
5.4 randomized datastructures
Krish_ver2
 
PPT
4.2 bst 02
Krish_ver2
 
PPTX
평범한 이야기[Intro: 2015 의기제]
대호 이
 
PPT
4.1 webminig
Krish_ver2
 
PPT
trabajo de cultural
argelures
 
PPT
2.4 mst kruskal’s
Krish_ver2
 
PPT
1.9 b trees eg 03
Krish_ver2
 
PPT
5.3 dyn algo-i
Krish_ver2
 
PPT
4.4 hashing02
Krish_ver2
 
PPT
1.9 b trees 02
Krish_ver2
 
PPT
4.2 bst 03
Krish_ver2
 
1.10.association mining 2
Krish_ver2
 
문제는 한글이 잘 구현되는가?
Choi Man Dream
 
CV Belinda Wahl 2015
Belinda Wahl
 
5.2 divede and conquer 03
Krish_ver2
 
nhận thiết kế clip quảng cáo giá tốt
raul110
 
РЕКЛАМНЫЕ МОДЕЛИ
Moscow State University of Printing Arts
 
RESUME-ARITRA BHOWMIK
Aritra Bhowmik
 
160607 14 sw교육_강의안
Choi Man Dream
 
Online Trading Concepts
Fxmoneyworld LTD
 
5.4 randomized datastructures
Krish_ver2
 
4.2 bst 02
Krish_ver2
 
평범한 이야기[Intro: 2015 의기제]
대호 이
 
4.1 webminig
Krish_ver2
 
trabajo de cultural
argelures
 
2.4 mst kruskal’s
Krish_ver2
 
1.9 b trees eg 03
Krish_ver2
 
5.3 dyn algo-i
Krish_ver2
 
4.4 hashing02
Krish_ver2
 
1.9 b trees 02
Krish_ver2
 
4.2 bst 03
Krish_ver2
 
Ad

Similar to 2.1 graph basic (20)

PPTX
NON-LINEAR DATA STRUCTURE-Graphs.pptx
Rajitha Reddy Alugati
 
PPT
Graphs
amudha arul
 
PPTX
DATA STRUCTURES unit 4.pptx
ShivamKrPathak
 
PPT
Lecture 5b graphs and hashing
Victor Palmar
 
PPT
Dsa.PPT
boltkat
 
PPT
chapter6.PPT
krish448427
 
PPTX
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
 
PPT
GRAPHS notes presentation of non linear data structure
rasinenicharishma24
 
PDF
Graphs
Dwight Sabio
 
PDF
09_DS_MCA_Graphs.pdf
Prasanna David
 
PPTX
6. Graphs
Mandeep Singh
 
PPT
Fallsem2015 16 cp4194-13-oct-2015_rm01_graphs
SnehilKeshari
 
PPTX
Lecture 14 data structures and algorithms
Aakash deep Singhal
 
PPT
GraphGraph data structureGraph data structure.ppt
jamnona
 
PPTX
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
pournima055
 
PDF
Graphhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pdf
timoemin50
 
PPTX
10.graph
jashobhan pradhan
 
PPTX
Data Structure of computer science and technology
bhaskarsai499
 
PDF
graphs in data structure for Btech students.pdf
soniasharmafdp
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
Rajitha Reddy Alugati
 
Graphs
amudha arul
 
DATA STRUCTURES unit 4.pptx
ShivamKrPathak
 
Lecture 5b graphs and hashing
Victor Palmar
 
Dsa.PPT
boltkat
 
chapter6.PPT
krish448427
 
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
 
GRAPHS notes presentation of non linear data structure
rasinenicharishma24
 
Graphs
Dwight Sabio
 
09_DS_MCA_Graphs.pdf
Prasanna David
 
6. Graphs
Mandeep Singh
 
Fallsem2015 16 cp4194-13-oct-2015_rm01_graphs
SnehilKeshari
 
Lecture 14 data structures and algorithms
Aakash deep Singhal
 
GraphGraph data structureGraph data structure.ppt
jamnona
 
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
pournima055
 
Graphhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.pdf
timoemin50
 
Data Structure of computer science and technology
bhaskarsai499
 
graphs in data structure for Btech students.pdf
soniasharmafdp
 
Ad

More from Krish_ver2 (20)

PPT
5.5 back tracking
Krish_ver2
 
PPT
5.5 back track
Krish_ver2
 
PPT
5.5 back tracking 02
Krish_ver2
 
PPT
5.4 randomized datastructures
Krish_ver2
 
PPT
5.4 randamized algorithm
Krish_ver2
 
PPT
5.3 dynamic programming 03
Krish_ver2
 
PPT
5.3 dynamic programming
Krish_ver2
 
PPT
5.2 divede and conquer 03
Krish_ver2
 
PPT
5.2 divide and conquer
Krish_ver2
 
PPT
5.1 greedyyy 02
Krish_ver2
 
PPT
5.1 greedy
Krish_ver2
 
PPT
5.1 greedy 03
Krish_ver2
 
PPT
4.4 hashing
Krish_ver2
 
PPT
4.4 hashing ext
Krish_ver2
 
PPT
4.4 external hashing
Krish_ver2
 
PPT
4.2 bst
Krish_ver2
 
PPT
4.1 sequentioal search
Krish_ver2
 
PPT
3.9 external sorting
Krish_ver2
 
PPT
3.8 quicksort
Krish_ver2
 
PPT
3.8 quick sort
Krish_ver2
 
5.5 back tracking
Krish_ver2
 
5.5 back track
Krish_ver2
 
5.5 back tracking 02
Krish_ver2
 
5.4 randomized datastructures
Krish_ver2
 
5.4 randamized algorithm
Krish_ver2
 
5.3 dynamic programming 03
Krish_ver2
 
5.3 dynamic programming
Krish_ver2
 
5.2 divede and conquer 03
Krish_ver2
 
5.2 divide and conquer
Krish_ver2
 
5.1 greedyyy 02
Krish_ver2
 
5.1 greedy
Krish_ver2
 
5.1 greedy 03
Krish_ver2
 
4.4 hashing
Krish_ver2
 
4.4 hashing ext
Krish_ver2
 
4.4 external hashing
Krish_ver2
 
4.2 bst
Krish_ver2
 
4.1 sequentioal search
Krish_ver2
 
3.9 external sorting
Krish_ver2
 
3.8 quicksort
Krish_ver2
 
3.8 quick sort
Krish_ver2
 

Recently uploaded (20)

PPTX
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
How to Configure Storno Accounting in Odoo 18 Accounting
Celine George
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
PPTX
ROLE OF ANTIOXIDANT IN EYE HEALTH MANAGEMENT.pptx
Subham Panja
 
PPTX
Presentation: Climate Citizenship Digital Education
Karl Donert
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PPTX
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
How to Configure Storno Accounting in Odoo 18 Accounting
Celine George
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
ROLE OF ANTIOXIDANT IN EYE HEALTH MANAGEMENT.pptx
Subham Panja
 
Presentation: Climate Citizenship Digital Education
Karl Donert
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 

2.1 graph basic

  • 1. Graph – Basic concepts
  • 2. Basic Concepts A graph is an ordered pair (V, E). V is the set of vertices. (You can think of them as integers 1, 2, …, n.) E is the set of edges. An edge is a pair of vertices: (u, v). Edges can be labeled with a weight: 6-Graphs 10
  • 3. Concepts: Directedness In a directed graph, the edges are “one-way.” So an edge (u, v) means you can go from u to v, but not vice versa. In an undirected graph, there is no direction on the edges: you can go either way. (Also, no self-loops.) 6-Graphs a self-loop
  • 4. Concepts: Adjacency Two vertices are adjacent if there is an edge between them. For a directed graph, u is adjacent to v iff there is an edge (v, u). 6-Graphs u w v u is adjacent to v. v is adjacent to u and w. w is adjacent to v. u w v u is adjacent to v. v is adjacent to w.
  • 5. Concepts: Degree Undirected graph: The degree of a vertex is the number of edges touching it. For a directed graph, the in-degree is the number of edges entering the vertex, and the out-degree is the number leaving it. The degree is the in-degree + the out-degree. 6-Graphs degree 4 in-degree 2, out-degree 1
  • 6. Concepts: Path A path is a sequence of adjacent vertices. The length of a path is the number of edges it contains, i.e. one less than the number of vertices. We write u ⇒ v if there is path from u to v. We say v is reachable from u. 6-Graphs 1 2 3 4 Is there a path from 1 to 4? What is its length? What about from 4 to 1? How many paths are there from 2 to 3? From 2 to 2? From 1 to 1?
  • 7. Concepts: Cycle •A cycle is a path of length at least 1 from a vertex to itself. •A graph with no cycles is acyclic. •A path with no cycles is a simple path. •The path <2, 3, 4, 2> is a cycle. 6-Graphs 1 2 3 4
  • 8. Concepts: Connectedness •An undirected graph is connected iff there is a path between any two vertices. •The adjacency graph of U.S. states has three connected components. Name them. •(We say a directed graph is strongly connected iff there is a path between any two vertices.) 6-Graphs An unconnected graph with three connected components.
  • 9. ADJACENCY MATRIX REPRESENTATION • 1 2 3 4 1 1 1 1 1 2 1 0 0 0 3 0 1 0 1 4 0 1 1 0
  • 10. ADJACENCY LIST REPRESENTATION  1 -> 1 -> 2 -> 3 -> 4 2 -> 1 3 -> 2 -> 4 4 -> 2 -> 3
  • 13. ASSESSMENT 1. Which of the following statements is true? A. A graph can drawn on paper in only one way. B. Graph vertices may be linked in any manner. C. A graph must have at least one vertex. D. A graph must have at least one edge. 
  • 14. CONTD.. 2. Suppose you have a game with 5 coins in a row and each coin can be heads or tails. What number of vertices might you expect to find in the state graph? A. 7 B. 10 C. 25 D. 32
  • 15. CONTD.. 3. Why is the state graph for tic-tac-toe a directed graph rather than an undirected graph? A. Once a move is made, it cannot be unmade. B. There is an odd number of vertices. C. There is an odd number of edges. D. There is more than one player in the game.
  • 16. CONTD.. 4. A simple graph has no loops. What other property must a simple graph have? A. It must be directed. B. It must be undirected. C. It must have at least one vertex. D. It must have no multiple edges.
  • 17. CONTD.. 5. Suppose you have a directed graph representing all the flights that an airline flies. What algorithm might be used to find the best sequence of connections from one city to another? A. Breadth first search. B. Depth first search. C. A cycle-finding algorithm. D. A shortest-path algorithm.