SlideShare a Scribd company logo
Lecture 16
Introduction to Graph
Abirami Sivaprasad
Vertices and Edges
Definition: A graph is a collection (nonempty set)
of vertices and edges
Vertices: can have names and properties(set of
nodes )
Edges: connect two vertices,
can be labeled,
can be directed
Adjacent vertices: there is an edge between
them
ExampleGraph1
Vertices: A,B,C,D
Edges: AB, AC, BC, CD
A B
C
D
A
C
B
D
Two ways to draw the same graph
Undirected graphs
When the edges in a graph have no direction, the graph is
called undirected
Directed Graph
When the edges in a graph have a direction, the
graph is called directed (or digraph)
Note: if the graph is directed,
the order of the vertices in each
edge is important !!
More definitions : Path
A list of vertices in which successive
vertices are connected by edges
A B C
B A C D
A B C A B C A B C D
B A B A C
A B
C
D
More definitions :
Simple Path
No vertex is repeated.
A B C D
D C A
D C B
A B
A B C
A B
C
D
More definitions : Cycle
Simple path with distinct edges, except
that the first vertex is equal to the last
A B C A
B A C B
C B A C
A B
C
D
A graph without cycles is called acyclic graph.
More definitions : Loop
An edge that connects the vertex with itself
A B
C
D
Connected and Disconnected graphs
Connected graph: There is a path between each
two vertices
Disconnected graph : There are at least two
vertices not connected by a path.
Examples of disconnected graphs:
A B
C
D
A B
C D
Graphs and Trees
Tree: an undirected graph with no cycles,
and a node chosen to be the root
A B
C
E
D
Source graph:
Graphs and Trees
A
C
E B
D
C
A
E
B
D
Tree1: root A Tree2: root C
A spanning tree of an undirected
graph
A sub-graph that contains all the vertices, and no cycles.
If we add any edge to the spanning tree, it forms a cycle, and
the tree becomes a graph
A B
C
D
A B
C
D
graph
spanning tree
Examples
A B
C D
A B
C D
A B
C D
All spanning trees
of the graph on
the previous slide
Complete graphs
Graphs with all edges present – each vertex is
connected to all other vertices
Dense graphs:
relatively few of
the possible
edges are
missing
Sparse graphs:
relatively few of
the possible
edges are
present
A B
C
D
E
A complete graph
Weighted graphs and Networks
Weighted graphs – weights are assigned to each
edge (e.g. road map)
Networks: directed weighted graphs (some theories
allow networks to be undirected)
A
B
D
C
3
2
4
1
2
Graph Representation
Adjacency matrix
Adjacency lists
Adjacency matrix – undirected
graphs
Vertices: A,B,C,D
Edges: AC, AB, AD, BD
A B C D
A 0 1 1 1
B 1 0 0 1
C 1 0 0 1
D 1 1 0 0
The matrix is symmetrical
A B
C
D
Adjacency matrix – directed graphs
Vertices: A,B,C,D
Edges: AC, AB, BD, DA
A B C D
A 0 1 1 0
B 0 0 0 1
C 0 0 0 0
D 1 0 0 0
A B
C
D
Adjacency lists – undirected graphs
Vertices: A,B,C,D
Edges: AC, AB, AD, BD
Heads lists
A B C D
B A D
C A
D A B
A B
C
D
Adjacency lists – directed graphs
Vertices: A,B,C,D
Edges: AC, AB, BD, DA
Heads lists
A B C
B D
C =
D A
A B
C
D
Thank u

More Related Content

What's hot (20)

PDF
Graphs in datastructures
LikhithaGunturi
 
PPT
1 4 segments, rays, parallel lines and planes
Huron School District
 
PPT
Geom 1point2
herbison
 
PDF
2.1 Points, Lines, and Planes
smiller5
 
PPTX
GRAPH THEORY
mathematicssac
 
PPTX
Math 7 geometry 01 undefined terms rev 2
Gilbert Joseph Abueg
 
PDF
Basics of geometry
Robert Tinaro
 
PPT
1 3 points, lines, planes
Huron School District
 
PPTX
Building blocks of geometry
Cinnaminson Public Schools
 
PPTX
Data structure graphs
Uma mohan
 
PDF
GEOMETRY: POINTS, LINES. PLANES
M, Michelle Jeannite
 
PPTX
diagrammatic presentation of data-bar diagram & pie diagram
anusha gupta
 
PPTX
Solid mensuration lecture #1
Denmar Marasigan
 
PPT
Building Blocks Of Geometry
acavis
 
PDF
1.1.1A Points, Lines, and Planes
smiller5
 
PPT
Area (math)
Christopher Masullo
 
PPTX
Point, Line and plane
Kristine Joy Ramirez
 
DOCX
Types of graphs
Thamizhendhi karthikeyan
 
PPTX
Graphs
PreethaPreetha5
 
PPTX
Triangles
Shubham Kala
 
Graphs in datastructures
LikhithaGunturi
 
1 4 segments, rays, parallel lines and planes
Huron School District
 
Geom 1point2
herbison
 
2.1 Points, Lines, and Planes
smiller5
 
GRAPH THEORY
mathematicssac
 
Math 7 geometry 01 undefined terms rev 2
Gilbert Joseph Abueg
 
Basics of geometry
Robert Tinaro
 
1 3 points, lines, planes
Huron School District
 
Building blocks of geometry
Cinnaminson Public Schools
 
Data structure graphs
Uma mohan
 
GEOMETRY: POINTS, LINES. PLANES
M, Michelle Jeannite
 
diagrammatic presentation of data-bar diagram & pie diagram
anusha gupta
 
Solid mensuration lecture #1
Denmar Marasigan
 
Building Blocks Of Geometry
acavis
 
1.1.1A Points, Lines, and Planes
smiller5
 
Area (math)
Christopher Masullo
 
Point, Line and plane
Kristine Joy Ramirez
 
Types of graphs
Thamizhendhi karthikeyan
 
Triangles
Shubham Kala
 

Similar to Lecture 16 graph introduction (20)

PPTX
Graph Theory
Rashmi Bhat
 
PPTX
Graphs.pptx
satvikkushwaha1
 
PPTX
ppt 1.pptx
ShasidharaniD
 
PDF
09_DS_MCA_Graphs.pdf
Prasanna David
 
PPT
Graphs
amudha arul
 
PPT
GraphGraph data structureGraph data structure.ppt
jamnona
 
PPTX
graph.pptx
DEEPAK948083
 
PDF
unit-3-dsa-graph introduction to grapgh and graph type
sayalijscoe2
 
PPTX
Slides Chapter10.1 10.2
showslidedump
 
PPTX
Chapter 6-DS(Introduction to Graph and its terminologies).pptx
nasalapurepallavi272
 
PPTX
Lecture 14 data structures and algorithms
Aakash deep Singhal
 
PPTX
unit5 graphs (DS).pptx
Sri Latha
 
PPTX
VANU no sql ppt.pptx
MJeyavarthini
 
PPTX
Vanmathy no sql
PriyadharshiniVS
 
PPSX
Unit-6 Graph.ppsx ppt
DhruvilSTATUS
 
PPTX
DSA THE LECTURE NUMMBER 213 OF AJKAKWWJWJNWJJWJWJWH .ppt
maryamzahra3366
 
PPT
Lecture 5b graphs and hashing
Victor Palmar
 
Graph Theory
Rashmi Bhat
 
Graphs.pptx
satvikkushwaha1
 
ppt 1.pptx
ShasidharaniD
 
09_DS_MCA_Graphs.pdf
Prasanna David
 
Graphs
amudha arul
 
GraphGraph data structureGraph data structure.ppt
jamnona
 
graph.pptx
DEEPAK948083
 
unit-3-dsa-graph introduction to grapgh and graph type
sayalijscoe2
 
Slides Chapter10.1 10.2
showslidedump
 
Chapter 6-DS(Introduction to Graph and its terminologies).pptx
nasalapurepallavi272
 
Lecture 14 data structures and algorithms
Aakash deep Singhal
 
unit5 graphs (DS).pptx
Sri Latha
 
VANU no sql ppt.pptx
MJeyavarthini
 
Vanmathy no sql
PriyadharshiniVS
 
Unit-6 Graph.ppsx ppt
DhruvilSTATUS
 
DSA THE LECTURE NUMMBER 213 OF AJKAKWWJWJNWJJWJWJWH .ppt
maryamzahra3366
 
Lecture 5b graphs and hashing
Victor Palmar
 
Ad

More from Abirami A (12)

PPTX
Lecture 3 time complexity
Abirami A
 
PPTX
Lecture 2 Data Structure Introduction
Abirami A
 
PPTX
Lecture 1 introduction
Abirami A
 
PPTX
Lecture 14 splay tree
Abirami A
 
PPTX
Lecture 16 graphs traversal
Abirami A
 
PPTX
Lecture 6 disjoint set
Abirami A
 
PPTX
Lecture 8 tree traversal
Abirami A
 
PPTX
Lecture 9 b tree
Abirami A
 
PPTX
Lecture 7 bst
Abirami A
 
PPTX
Lecture 6 tree traversal
Abirami A
 
PPT
Lecture 5 tree.pptx
Abirami A
 
PPTX
Lecture 1 sorting insertion & shell sort
Abirami A
 
Lecture 3 time complexity
Abirami A
 
Lecture 2 Data Structure Introduction
Abirami A
 
Lecture 1 introduction
Abirami A
 
Lecture 14 splay tree
Abirami A
 
Lecture 16 graphs traversal
Abirami A
 
Lecture 6 disjoint set
Abirami A
 
Lecture 8 tree traversal
Abirami A
 
Lecture 9 b tree
Abirami A
 
Lecture 7 bst
Abirami A
 
Lecture 6 tree traversal
Abirami A
 
Lecture 5 tree.pptx
Abirami A
 
Lecture 1 sorting insertion & shell sort
Abirami A
 
Ad

Recently uploaded (20)

PDF
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPT
inherently safer design for engineering.ppt
DhavalShah616893
 
PDF
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
PPTX
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
PDF
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
PPTX
Electron Beam Machining for Production Process
Rajshahi University of Engineering & Technology(RUET), Bangladesh
 
PPTX
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
PPTX
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
PPTX
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PDF
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
PPTX
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PDF
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
PDF
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
inherently safer design for engineering.ppt
DhavalShah616893
 
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
Electron Beam Machining for Production Process
Rajshahi University of Engineering & Technology(RUET), Bangladesh
 
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
Thermal runway and thermal stability.pptx
godow93766
 
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
MOBILE AND WEB BASED REMOTE BUSINESS MONITORING SYSTEM
ijait
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 

Lecture 16 graph introduction

  • 1. Lecture 16 Introduction to Graph Abirami Sivaprasad
  • 2. Vertices and Edges Definition: A graph is a collection (nonempty set) of vertices and edges Vertices: can have names and properties(set of nodes ) Edges: connect two vertices, can be labeled, can be directed Adjacent vertices: there is an edge between them
  • 3. ExampleGraph1 Vertices: A,B,C,D Edges: AB, AC, BC, CD A B C D A C B D Two ways to draw the same graph
  • 4. Undirected graphs When the edges in a graph have no direction, the graph is called undirected
  • 5. Directed Graph When the edges in a graph have a direction, the graph is called directed (or digraph) Note: if the graph is directed, the order of the vertices in each edge is important !!
  • 6. More definitions : Path A list of vertices in which successive vertices are connected by edges A B C B A C D A B C A B C A B C D B A B A C A B C D
  • 7. More definitions : Simple Path No vertex is repeated. A B C D D C A D C B A B A B C A B C D
  • 8. More definitions : Cycle Simple path with distinct edges, except that the first vertex is equal to the last A B C A B A C B C B A C A B C D A graph without cycles is called acyclic graph.
  • 9. More definitions : Loop An edge that connects the vertex with itself A B C D
  • 10. Connected and Disconnected graphs Connected graph: There is a path between each two vertices Disconnected graph : There are at least two vertices not connected by a path. Examples of disconnected graphs: A B C D A B C D
  • 11. Graphs and Trees Tree: an undirected graph with no cycles, and a node chosen to be the root A B C E D Source graph:
  • 12. Graphs and Trees A C E B D C A E B D Tree1: root A Tree2: root C
  • 13. A spanning tree of an undirected graph A sub-graph that contains all the vertices, and no cycles. If we add any edge to the spanning tree, it forms a cycle, and the tree becomes a graph A B C D A B C D graph spanning tree
  • 14. Examples A B C D A B C D A B C D All spanning trees of the graph on the previous slide
  • 15. Complete graphs Graphs with all edges present – each vertex is connected to all other vertices Dense graphs: relatively few of the possible edges are missing Sparse graphs: relatively few of the possible edges are present A B C D E A complete graph
  • 16. Weighted graphs and Networks Weighted graphs – weights are assigned to each edge (e.g. road map) Networks: directed weighted graphs (some theories allow networks to be undirected) A B D C 3 2 4 1 2
  • 18. Adjacency matrix – undirected graphs Vertices: A,B,C,D Edges: AC, AB, AD, BD A B C D A 0 1 1 1 B 1 0 0 1 C 1 0 0 1 D 1 1 0 0 The matrix is symmetrical A B C D
  • 19. Adjacency matrix – directed graphs Vertices: A,B,C,D Edges: AC, AB, BD, DA A B C D A 0 1 1 0 B 0 0 0 1 C 0 0 0 0 D 1 0 0 0 A B C D
  • 20. Adjacency lists – undirected graphs Vertices: A,B,C,D Edges: AC, AB, AD, BD Heads lists A B C D B A D C A D A B A B C D
  • 21. Adjacency lists – directed graphs Vertices: A,B,C,D Edges: AC, AB, BD, DA Heads lists A B C B D C = D A A B C D