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

PPT
2.1 graph basic
PPTX
Graph therory
PDF
Talk on Graph Theory - I
PPTX
Data structure
PPTX
Graphical reprsentation dsa (DATA STRUCTURE ALGORITHM)
PDF
Geometry semester 1 vocabulary terms
PPTX
Graph theory
PPT
Points, Rays, And Planes
2.1 graph basic
Graph therory
Talk on Graph Theory - I
Data structure
Graphical reprsentation dsa (DATA STRUCTURE ALGORITHM)
Geometry semester 1 vocabulary terms
Graph theory
Points, Rays, And Planes

What's hot (20)

PDF
Graphs in datastructures
PPT
1 4 segments, rays, parallel lines and planes
PPT
Geom 1point2
PDF
2.1 Points, Lines, and Planes
PPTX
GRAPH THEORY
PPTX
Math 7 geometry 01 undefined terms rev 2
PDF
Basics of geometry
PPT
1 3 points, lines, planes
PPTX
Building blocks of geometry
PPTX
Data structure graphs
PDF
GEOMETRY: POINTS, LINES. PLANES
PPTX
diagrammatic presentation of data-bar diagram & pie diagram
PPTX
Solid mensuration lecture #1
PPT
Building Blocks Of Geometry
PDF
1.1.1A Points, Lines, and Planes
PPT
Area (math)
PPTX
Point, Line and plane
DOCX
Types of graphs
PPTX
PPTX
Triangles
Graphs in datastructures
1 4 segments, rays, parallel lines and planes
Geom 1point2
2.1 Points, Lines, and Planes
GRAPH THEORY
Math 7 geometry 01 undefined terms rev 2
Basics of geometry
1 3 points, lines, planes
Building blocks of geometry
Data structure graphs
GEOMETRY: POINTS, LINES. PLANES
diagrammatic presentation of data-bar diagram & pie diagram
Solid mensuration lecture #1
Building Blocks Of Geometry
1.1.1A Points, Lines, and Planes
Area (math)
Point, Line and plane
Types of graphs
Triangles
Ad

Similar to Lecture 16 graph introduction (20)

PPTX
DSA THE LECTURE NUMMBER 213 OF AJKAKWWJWJNWJJWJWJWH .ppt
PPTX
Data Structures - Introduction to Graph.pptx
PPTX
Graph terminology and algorithm and tree.pptx
PPTX
graphs presentation .pptx
PPT
Basics of graph
PPTX
Graph theory
DOC
Graph theory1234
PPTX
Graphs Basics.pptx
PPTX
Graph Basic In Data structure
PPT
Data Structures-Non Linear DataStructures-Graphs
PPT
UNIT III discrete mathematice notes availiable
PPT
Lecture 5b graphs and hashing
PPT
PPTX
Slides Chapter10.1 10.2
PPTX
Chapter 6-DS(Introduction to Graph and its terminologies).pptx
PPTX
Graph Theory
PPT
GraphGraph data structureGraph data structure.ppt
PPT
GraphGraph data structureGraph data structure.ppt
PPTX
Graph data structures for ppt for understanding.pptx
PPT
Graph Introduction.ppt
DSA THE LECTURE NUMMBER 213 OF AJKAKWWJWJNWJJWJWJWH .ppt
Data Structures - Introduction to Graph.pptx
Graph terminology and algorithm and tree.pptx
graphs presentation .pptx
Basics of graph
Graph theory
Graph theory1234
Graphs Basics.pptx
Graph Basic In Data structure
Data Structures-Non Linear DataStructures-Graphs
UNIT III discrete mathematice notes availiable
Lecture 5b graphs and hashing
Slides Chapter10.1 10.2
Chapter 6-DS(Introduction to Graph and its terminologies).pptx
Graph Theory
GraphGraph data structureGraph data structure.ppt
GraphGraph data structureGraph data structure.ppt
Graph data structures for ppt for understanding.pptx
Graph Introduction.ppt
Ad

More from Abirami A (12)

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

Recently uploaded (20)

PPT
Project quality management in manufacturing
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Digital Logic Computer Design lecture notes
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
web development for engineering and engineering
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
composite construction of structures.pdf
PPTX
Sustainable Sites - Green Building Construction
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Project quality management in manufacturing
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Mechanical Engineering MATERIALS Selection
Internet of Things (IOT) - A guide to understanding
Digital Logic Computer Design lecture notes
Foundation to blockchain - A guide to Blockchain Tech
CYBER-CRIMES AND SECURITY A guide to understanding
R24 SURVEYING LAB MANUAL for civil enggi
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Lecture Notes Electrical Wiring System Components
CH1 Production IntroductoryConcepts.pptx
web development for engineering and engineering
Automation-in-Manufacturing-Chapter-Introduction.pdf
Operating System & Kernel Study Guide-1 - converted.pdf
composite construction of structures.pdf
Sustainable Sites - Green Building Construction
bas. eng. economics group 4 presentation 1.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx

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