SlideShare a Scribd company logo
Graph and Its Applications
1
• Nonlinear data Structures.
• A graph G consists of two properties:
(a) A set V of elements called vertices or nodes.
(b) A set E of connectors called edges such that each edge e is identified as
e = (u,v) (unordered pair of vertices). Here is a edge between u and v and
they are said to be the adjacent nodes or neighbors .
 The order of a graph is |V| (the number of vertices).
 A graph's size is |E|, the number of edges.
 A tree is a graph with no cycle.
Example:
A B
C D
E
In Graph G1
• 5 Vertices:{A, B, C, D, E}
• 6 Edges: {[A,B], [A,C], [B,D],
[B,E], [C,D], [D,E]}
Figure1: A graph G1
GraphGraph
2
Definitions
• Isolated Node: A vertex u with no edges.
• Path: A path P of length n from a node u to node v is defined as a sequence n+1 nodes
such that P=(v0, v1, ….vn).
• Simple Path: if all nodes in path P are distinct.
• Cycle: The starting and the ending vertices are the same.
Example:
A B
C D
E
In graph G2
• Isolate Node: E
• Path P from A to C : A -> B -> D -> C
• Length of the Path p : 3
Figure2: Graph G2
3
• Connected Graph: A graph is called connected if there is a simple path between any
two of its nodes.
Example:
• Complete Graph: A graph G is complete if every node in graph G is adjacent to every
other nodes. A complete graph with n nodes will have n(n-1)/2 edges.
Example:
C
A B
D
A B
C D
4
Types of GraphTypes of Graph
In Graph G
• Vertices, n = 4
• Edges: n(n-1)/2 = 6
• Tree Graph: A connected graph with no cycle. If a tree graph has m nodes, then there are
m-1 edges.
Example:
• Unweighted Graph: A graph G is said to be un weighted if its edges are not assigned
any value.
Example:
• Weighted Graph: A labeled graph where each edge is assigned a numerical value w(e).
Example:
A B
C D
A B
C D
A B
C D
5
12
7
9
2
5
• Multigraph: A multigraph has the following properties:
(a) Multiple Edges within the same nodes.
(b) Loops
• Directed Graph: Each edge in graph has a direction such that e = (u,v), ie. e begins at u
and ends at v.
Example:
A B
C D
A B
C D
6
• Undirected Graph: If there is no direction between the edges:.
Example: A B
C D
• Degree of a Node: No. of edges connected to a node.
(a) Indegree: No. of edges ending at a node.
(b) Outdegree: No. of edges beginning at a node.
Example:
A B
C D
In graph G
Indeg(A)= 0 Outdeg(A)=2
Indeg(B)= 3 Outdeg(B)= 0
Indeg(C)= 1 Outdeg(C)= 2
Indeg(D)= 1 Outdeg(D)= 1Figure 3: Directed Graph G
Note:
• A node u is called source if it has a positive outdegree and 0 indegree (A).
• A node u is called sink if it has a positive indegree and 0 outdegree (B).
• For a directed graph, a loop adds one to the indegree and one to the outdegree.
• For undirected graph, a loop adds two to the degree.
7
Representation of Graph
(1) Sequential Representation / Adjacency Matrix
(2) Linked Representation / Adjucency List
Sequential Representation/ Adjacency Matrix
• Use Adjacency Matrix (Boolean Matrix).
• An adjacency matrix A = (aij) of a graph G is the m x m matrix defined as follows:
aij = 1 if vi is adjacent to vj
0 otherwise
Example: A B
C D
A B C D
A 0 1 1 0
B 0 0 0 0
C 0 1 0 1
D 0 1 0 0
Figure 4: A Directed Graph & Its Adjacency Matrix 8
Adjacency matrix representation
of a weighted graph
9
Linked Representation of a GraphLinked Representation of a Graph
•Adjacency List:
An array of linked lists is used. Size of the array is equal to number of vertices. Let the
array be array[]. An entry array[i] represents the linked list of vertices adjacent to the ith
vertex. This representation can also be used to represent a weighted graph. The weights of
edges can be stored in nodes of linked lists. Following is adjacency list representation of
the above graph.
Example:
Figure: Directed Graph and Corresponding Adjacency List
10
08/15/17 11
Which Representation Is Better?
• The adjacency-list is usually preferred if the graph is sparse (having few edges).
• The adjacency-matrix is preferred if the graph is dense (the number of edges is
close to the maximal number of edges).
If |E| ≈ |V|2
the graph is dense
If |E| ≈ |V| the graph is sparse
Dense Graph Sparse Graph
Figure: Dense and Sparse Graph
12
13
END!!!

More Related Content

What's hot

Graph coloring
Graph coloringGraph coloring
Graph coloring
Rashika Ahuja
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
V.V.Vanniaperumal College for Women
 
Network flows
Network flowsNetwork flows
Network flows
Richa Bandlas
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
Gajanand Sharma
 
Graph coloring and_applications
Graph coloring and_applicationsGraph coloring and_applications
Graph coloring and_applicationsmohammad alkhalil
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
shashidharPapishetty
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
Graph theory and its applications
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applications
Manikanta satyala
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
Animesh Chaturvedi
 
Vertex cover problem
Vertex cover problemVertex cover problem
Vertex cover problem
Ginusaju
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data StructureAnuj Modi
 
Graph theory
Graph theoryGraph theory
Graph theory
Muthulakshmilakshmi2
 
Graph theory presentation
Graph theory presentationGraph theory presentation
Graph theory presentation
Aliul Kadir Akib
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
Euler and hamilton paths
Euler and hamilton pathsEuler and hamilton paths
Euler and hamilton paths
University of Potsdam
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
Yosuke Mizutani
 
Graph representation
Graph representationGraph representation
Graph representationTech_MX
 
GRAPH COLORING AND ITS APPLICATIONS
GRAPH COLORING AND ITS APPLICATIONSGRAPH COLORING AND ITS APPLICATIONS
GRAPH COLORING AND ITS APPLICATIONS
Manojit Chakraborty
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
Ehsan Hamzei
 

What's hot (20)

Graph coloring
Graph coloringGraph coloring
Graph coloring
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
Network flows
Network flowsNetwork flows
Network flows
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
 
Graph coloring and_applications
Graph coloring and_applicationsGraph coloring and_applications
Graph coloring and_applications
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
 
Graph theory and its applications
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applications
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Vertex cover problem
Vertex cover problemVertex cover problem
Vertex cover problem
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Graph theory presentation
Graph theory presentationGraph theory presentation
Graph theory presentation
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Euler and hamilton paths
Euler and hamilton pathsEuler and hamilton paths
Euler and hamilton paths
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
 
Graph representation
Graph representationGraph representation
Graph representation
 
GRAPH COLORING AND ITS APPLICATIONS
GRAPH COLORING AND ITS APPLICATIONSGRAPH COLORING AND ITS APPLICATIONS
GRAPH COLORING AND ITS APPLICATIONS
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 

Similar to Basics of graph

Graphs in datastructures
Graphs in datastructuresGraphs in datastructures
Graphs in datastructures
LikhithaGunturi
 
Graphs.pptx
Graphs.pptxGraphs.pptx
Graphs.pptx
satvikkushwaha1
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
Rashmi Bhat
 
graphs presentation .pptx
graphs presentation .pptxgraphs presentation .pptx
graphs presentation .pptx
ssuser800a48
 
Graphs.pdf
Graphs.pdfGraphs.pdf
Graphs.pdf
pubggaming58982
 
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxGraph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptx
asimshahzad8611
 
Graphs
GraphsGraphs
Graphs
amudha arul
 
Graph ASS DBATU.pptx
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptx
ARVIND SARDAR
 
graph ASS (1).ppt
graph ASS (1).pptgraph ASS (1).ppt
graph ASS (1).ppt
ARVIND SARDAR
 
Graphs (Models & Terminology)
Graphs (Models & Terminology)Graphs (Models & Terminology)
Graphs (Models & Terminology)
zunaira saleem
 
Chapter 1
Chapter   1Chapter   1
Chapter 1
MeeraMeghpara
 
Graph therory
Graph theroryGraph therory
Graph therory
mohanrathod18
 
Graphs
GraphsGraphs
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
Prasanna David
 
Graph-theory.ppt
Graph-theory.pptGraph-theory.ppt
Graph-theory.ppt
AlpaSinghRajput1
 
CS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on GraphsCS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on Graphs
ssuser034ce1
 
CS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on GraphsCS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on Graphs
ssuser034ce1
 
6. Graphs
6. Graphs6. Graphs
6. Graphs
Mandeep Singh
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx ppt
DhruvilSTATUS
 

Similar to Basics of graph (20)

Graphs in datastructures
Graphs in datastructuresGraphs in datastructures
Graphs in datastructures
 
Graphs.pptx
Graphs.pptxGraphs.pptx
Graphs.pptx
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
graphs presentation .pptx
graphs presentation .pptxgraphs presentation .pptx
graphs presentation .pptx
 
Graphs.pdf
Graphs.pdfGraphs.pdf
Graphs.pdf
 
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxGraph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptx
 
Graphs
GraphsGraphs
Graphs
 
Graph ASS DBATU.pptx
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptx
 
graph ASS (1).ppt
graph ASS (1).pptgraph ASS (1).ppt
graph ASS (1).ppt
 
Graphs (Models & Terminology)
Graphs (Models & Terminology)Graphs (Models & Terminology)
Graphs (Models & Terminology)
 
Chapter 1
Chapter   1Chapter   1
Chapter 1
 
Graph therory
Graph theroryGraph therory
Graph therory
 
Graphs
GraphsGraphs
Graphs
 
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
 
Graph-theory.ppt
Graph-theory.pptGraph-theory.ppt
Graph-theory.ppt
 
Graph.ppt
Graph.pptGraph.ppt
Graph.ppt
 
CS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on GraphsCS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on Graphs
 
CS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on GraphsCS-102 Data Structure lectures on Graphs
CS-102 Data Structure lectures on Graphs
 
6. Graphs
6. Graphs6. Graphs
6. Graphs
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx ppt
 

More from Khaled Sany

3D Display Method
3D Display Method3D Display Method
3D Display Method
Khaled Sany
 
LiFi (light fidility)
LiFi (light fidility)LiFi (light fidility)
LiFi (light fidility)
Khaled Sany
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessor
Khaled Sany
 
LED [light-emitting-diode]
LED [light-emitting-diode]LED [light-emitting-diode]
LED [light-emitting-diode]
Khaled Sany
 
Statistic and Application
Statistic and ApplicationStatistic and Application
Statistic and Application
Khaled Sany
 
Dark and Deep web
Dark and Deep webDark and Deep web
Dark and Deep web
Khaled Sany
 

More from Khaled Sany (6)

3D Display Method
3D Display Method3D Display Method
3D Display Method
 
LiFi (light fidility)
LiFi (light fidility)LiFi (light fidility)
LiFi (light fidility)
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessor
 
LED [light-emitting-diode]
LED [light-emitting-diode]LED [light-emitting-diode]
LED [light-emitting-diode]
 
Statistic and Application
Statistic and ApplicationStatistic and Application
Statistic and Application
 
Dark and Deep web
Dark and Deep webDark and Deep web
Dark and Deep web
 

Recently uploaded

一比一原版(MMU毕业证书)曼彻斯特城市大学毕业证成绩单如何办理
一比一原版(MMU毕业证书)曼彻斯特城市大学毕业证成绩单如何办理一比一原版(MMU毕业证书)曼彻斯特城市大学毕业证成绩单如何办理
一比一原版(MMU毕业证书)曼彻斯特城市大学毕业证成绩单如何办理
7sd8fier
 
Portfolio.pdf
Portfolio.pdfPortfolio.pdf
Portfolio.pdf
garcese
 
一比一原版(UAL毕业证书)伦敦艺术大学毕业证成绩单如何办理
一比一原版(UAL毕业证书)伦敦艺术大学毕业证成绩单如何办理一比一原版(UAL毕业证书)伦敦艺术大学毕业证成绩单如何办理
一比一原版(UAL毕业证书)伦敦艺术大学毕业证成绩单如何办理
708pb191
 
Common Designing Mistakes and How to avoid them
Common Designing Mistakes and How to avoid themCommon Designing Mistakes and How to avoid them
Common Designing Mistakes and How to avoid them
madhavlakhanpal29
 
Top 5 Indian Style Modular Kitchen Designs
Top 5 Indian Style Modular Kitchen DesignsTop 5 Indian Style Modular Kitchen Designs
Top 5 Indian Style Modular Kitchen Designs
Finzo Kitchens
 
Коричневый и Кремовый Деликатный Органический Копирайтер Фрилансер Марке...
Коричневый и Кремовый Деликатный Органический Копирайтер Фрилансер Марке...Коричневый и Кремовый Деликатный Органический Копирайтер Фрилансер Марке...
Коричневый и Кремовый Деликатный Органический Копирайтер Фрилансер Марке...
ameli25062005
 
Design Thinking Design thinking Design thinking
Design Thinking Design thinking Design thinkingDesign Thinking Design thinking Design thinking
Design Thinking Design thinking Design thinking
cy0krjxt
 
Expert Accessory Dwelling Unit (ADU) Drafting Services
Expert Accessory Dwelling Unit (ADU) Drafting ServicesExpert Accessory Dwelling Unit (ADU) Drafting Services
Expert Accessory Dwelling Unit (ADU) Drafting Services
ResDraft
 
一比一原版(毕业证)长崎大学毕业证成绩单如何办理
一比一原版(毕业证)长崎大学毕业证成绩单如何办理一比一原版(毕业证)长崎大学毕业证成绩单如何办理
一比一原版(毕业证)长崎大学毕业证成绩单如何办理
taqyed
 
Book Formatting: Quality Control Checks for Designers
Book Formatting: Quality Control Checks for DesignersBook Formatting: Quality Control Checks for Designers
Book Formatting: Quality Control Checks for Designers
Confidence Ago
 
Can AI do good? at 'offtheCanvas' India HCI prelude
Can AI do good? at 'offtheCanvas' India HCI preludeCan AI do good? at 'offtheCanvas' India HCI prelude
Can AI do good? at 'offtheCanvas' India HCI prelude
Alan Dix
 
Between Filth and Fortune- Urban Cattle Foraging Realities by Devi S Nair, An...
Between Filth and Fortune- Urban Cattle Foraging Realities by Devi S Nair, An...Between Filth and Fortune- Urban Cattle Foraging Realities by Devi S Nair, An...
Between Filth and Fortune- Urban Cattle Foraging Realities by Devi S Nair, An...
Mansi Shah
 
PORTFOLIO FABIANA VILLANI ARCHITECTURE.pdf
PORTFOLIO FABIANA VILLANI ARCHITECTURE.pdfPORTFOLIO FABIANA VILLANI ARCHITECTURE.pdf
PORTFOLIO FABIANA VILLANI ARCHITECTURE.pdf
fabianavillanib
 
Transforming Brand Perception and Boosting Profitability
Transforming Brand Perception and Boosting ProfitabilityTransforming Brand Perception and Boosting Profitability
Transforming Brand Perception and Boosting Profitability
aaryangarg12
 
一比一原版(Bristol毕业证书)布里斯托大学毕业证成绩单如何办理
一比一原版(Bristol毕业证书)布里斯托大学毕业证成绩单如何办理一比一原版(Bristol毕业证书)布里斯托大学毕业证成绩单如何办理
一比一原版(Bristol毕业证书)布里斯托大学毕业证成绩单如何办理
smpc3nvg
 
Borys Sutkowski portfolio interior design
Borys Sutkowski portfolio interior designBorys Sutkowski portfolio interior design
Borys Sutkowski portfolio interior design
boryssutkowski
 
Design Thinking Design thinking Design thinking
Design Thinking Design thinking Design thinkingDesign Thinking Design thinking Design thinking
Design Thinking Design thinking Design thinking
cy0krjxt
 
20 slides of research movie and artists .pdf
20 slides of research movie and artists .pdf20 slides of research movie and artists .pdf
20 slides of research movie and artists .pdf
ameli25062005
 
一比一原版(Bolton毕业证书)博尔顿大学毕业证成绩单如何办理
一比一原版(Bolton毕业证书)博尔顿大学毕业证成绩单如何办理一比一原版(Bolton毕业证书)博尔顿大学毕业证成绩单如何办理
一比一原版(Bolton毕业证书)博尔顿大学毕业证成绩单如何办理
h7j5io0
 
CA OFFICE office office office _VIEWS.pdf
CA OFFICE office office office _VIEWS.pdfCA OFFICE office office office _VIEWS.pdf
CA OFFICE office office office _VIEWS.pdf
SudhanshuMandlik
 

Recently uploaded (20)

一比一原版(MMU毕业证书)曼彻斯特城市大学毕业证成绩单如何办理
一比一原版(MMU毕业证书)曼彻斯特城市大学毕业证成绩单如何办理一比一原版(MMU毕业证书)曼彻斯特城市大学毕业证成绩单如何办理
一比一原版(MMU毕业证书)曼彻斯特城市大学毕业证成绩单如何办理
 
Portfolio.pdf
Portfolio.pdfPortfolio.pdf
Portfolio.pdf
 
一比一原版(UAL毕业证书)伦敦艺术大学毕业证成绩单如何办理
一比一原版(UAL毕业证书)伦敦艺术大学毕业证成绩单如何办理一比一原版(UAL毕业证书)伦敦艺术大学毕业证成绩单如何办理
一比一原版(UAL毕业证书)伦敦艺术大学毕业证成绩单如何办理
 
Common Designing Mistakes and How to avoid them
Common Designing Mistakes and How to avoid themCommon Designing Mistakes and How to avoid them
Common Designing Mistakes and How to avoid them
 
Top 5 Indian Style Modular Kitchen Designs
Top 5 Indian Style Modular Kitchen DesignsTop 5 Indian Style Modular Kitchen Designs
Top 5 Indian Style Modular Kitchen Designs
 
Коричневый и Кремовый Деликатный Органический Копирайтер Фрилансер Марке...
Коричневый и Кремовый Деликатный Органический Копирайтер Фрилансер Марке...Коричневый и Кремовый Деликатный Органический Копирайтер Фрилансер Марке...
Коричневый и Кремовый Деликатный Органический Копирайтер Фрилансер Марке...
 
Design Thinking Design thinking Design thinking
Design Thinking Design thinking Design thinkingDesign Thinking Design thinking Design thinking
Design Thinking Design thinking Design thinking
 
Expert Accessory Dwelling Unit (ADU) Drafting Services
Expert Accessory Dwelling Unit (ADU) Drafting ServicesExpert Accessory Dwelling Unit (ADU) Drafting Services
Expert Accessory Dwelling Unit (ADU) Drafting Services
 
一比一原版(毕业证)长崎大学毕业证成绩单如何办理
一比一原版(毕业证)长崎大学毕业证成绩单如何办理一比一原版(毕业证)长崎大学毕业证成绩单如何办理
一比一原版(毕业证)长崎大学毕业证成绩单如何办理
 
Book Formatting: Quality Control Checks for Designers
Book Formatting: Quality Control Checks for DesignersBook Formatting: Quality Control Checks for Designers
Book Formatting: Quality Control Checks for Designers
 
Can AI do good? at 'offtheCanvas' India HCI prelude
Can AI do good? at 'offtheCanvas' India HCI preludeCan AI do good? at 'offtheCanvas' India HCI prelude
Can AI do good? at 'offtheCanvas' India HCI prelude
 
Between Filth and Fortune- Urban Cattle Foraging Realities by Devi S Nair, An...
Between Filth and Fortune- Urban Cattle Foraging Realities by Devi S Nair, An...Between Filth and Fortune- Urban Cattle Foraging Realities by Devi S Nair, An...
Between Filth and Fortune- Urban Cattle Foraging Realities by Devi S Nair, An...
 
PORTFOLIO FABIANA VILLANI ARCHITECTURE.pdf
PORTFOLIO FABIANA VILLANI ARCHITECTURE.pdfPORTFOLIO FABIANA VILLANI ARCHITECTURE.pdf
PORTFOLIO FABIANA VILLANI ARCHITECTURE.pdf
 
Transforming Brand Perception and Boosting Profitability
Transforming Brand Perception and Boosting ProfitabilityTransforming Brand Perception and Boosting Profitability
Transforming Brand Perception and Boosting Profitability
 
一比一原版(Bristol毕业证书)布里斯托大学毕业证成绩单如何办理
一比一原版(Bristol毕业证书)布里斯托大学毕业证成绩单如何办理一比一原版(Bristol毕业证书)布里斯托大学毕业证成绩单如何办理
一比一原版(Bristol毕业证书)布里斯托大学毕业证成绩单如何办理
 
Borys Sutkowski portfolio interior design
Borys Sutkowski portfolio interior designBorys Sutkowski portfolio interior design
Borys Sutkowski portfolio interior design
 
Design Thinking Design thinking Design thinking
Design Thinking Design thinking Design thinkingDesign Thinking Design thinking Design thinking
Design Thinking Design thinking Design thinking
 
20 slides of research movie and artists .pdf
20 slides of research movie and artists .pdf20 slides of research movie and artists .pdf
20 slides of research movie and artists .pdf
 
一比一原版(Bolton毕业证书)博尔顿大学毕业证成绩单如何办理
一比一原版(Bolton毕业证书)博尔顿大学毕业证成绩单如何办理一比一原版(Bolton毕业证书)博尔顿大学毕业证成绩单如何办理
一比一原版(Bolton毕业证书)博尔顿大学毕业证成绩单如何办理
 
CA OFFICE office office office _VIEWS.pdf
CA OFFICE office office office _VIEWS.pdfCA OFFICE office office office _VIEWS.pdf
CA OFFICE office office office _VIEWS.pdf
 

Basics of graph

  • 1. Graph and Its Applications 1
  • 2. • Nonlinear data Structures. • A graph G consists of two properties: (a) A set V of elements called vertices or nodes. (b) A set E of connectors called edges such that each edge e is identified as e = (u,v) (unordered pair of vertices). Here is a edge between u and v and they are said to be the adjacent nodes or neighbors .  The order of a graph is |V| (the number of vertices).  A graph's size is |E|, the number of edges.  A tree is a graph with no cycle. Example: A B C D E In Graph G1 • 5 Vertices:{A, B, C, D, E} • 6 Edges: {[A,B], [A,C], [B,D], [B,E], [C,D], [D,E]} Figure1: A graph G1 GraphGraph 2
  • 3. Definitions • Isolated Node: A vertex u with no edges. • Path: A path P of length n from a node u to node v is defined as a sequence n+1 nodes such that P=(v0, v1, ….vn). • Simple Path: if all nodes in path P are distinct. • Cycle: The starting and the ending vertices are the same. Example: A B C D E In graph G2 • Isolate Node: E • Path P from A to C : A -> B -> D -> C • Length of the Path p : 3 Figure2: Graph G2 3
  • 4. • Connected Graph: A graph is called connected if there is a simple path between any two of its nodes. Example: • Complete Graph: A graph G is complete if every node in graph G is adjacent to every other nodes. A complete graph with n nodes will have n(n-1)/2 edges. Example: C A B D A B C D 4 Types of GraphTypes of Graph In Graph G • Vertices, n = 4 • Edges: n(n-1)/2 = 6
  • 5. • Tree Graph: A connected graph with no cycle. If a tree graph has m nodes, then there are m-1 edges. Example: • Unweighted Graph: A graph G is said to be un weighted if its edges are not assigned any value. Example: • Weighted Graph: A labeled graph where each edge is assigned a numerical value w(e). Example: A B C D A B C D A B C D 5 12 7 9 2 5
  • 6. • Multigraph: A multigraph has the following properties: (a) Multiple Edges within the same nodes. (b) Loops • Directed Graph: Each edge in graph has a direction such that e = (u,v), ie. e begins at u and ends at v. Example: A B C D A B C D 6 • Undirected Graph: If there is no direction between the edges:. Example: A B C D
  • 7. • Degree of a Node: No. of edges connected to a node. (a) Indegree: No. of edges ending at a node. (b) Outdegree: No. of edges beginning at a node. Example: A B C D In graph G Indeg(A)= 0 Outdeg(A)=2 Indeg(B)= 3 Outdeg(B)= 0 Indeg(C)= 1 Outdeg(C)= 2 Indeg(D)= 1 Outdeg(D)= 1Figure 3: Directed Graph G Note: • A node u is called source if it has a positive outdegree and 0 indegree (A). • A node u is called sink if it has a positive indegree and 0 outdegree (B). • For a directed graph, a loop adds one to the indegree and one to the outdegree. • For undirected graph, a loop adds two to the degree. 7
  • 8. Representation of Graph (1) Sequential Representation / Adjacency Matrix (2) Linked Representation / Adjucency List Sequential Representation/ Adjacency Matrix • Use Adjacency Matrix (Boolean Matrix). • An adjacency matrix A = (aij) of a graph G is the m x m matrix defined as follows: aij = 1 if vi is adjacent to vj 0 otherwise Example: A B C D A B C D A 0 1 1 0 B 0 0 0 0 C 0 1 0 1 D 0 1 0 0 Figure 4: A Directed Graph & Its Adjacency Matrix 8
  • 10. Linked Representation of a GraphLinked Representation of a Graph •Adjacency List: An array of linked lists is used. Size of the array is equal to number of vertices. Let the array be array[]. An entry array[i] represents the linked list of vertices adjacent to the ith vertex. This representation can also be used to represent a weighted graph. The weights of edges can be stored in nodes of linked lists. Following is adjacency list representation of the above graph. Example: Figure: Directed Graph and Corresponding Adjacency List 10
  • 12. Which Representation Is Better? • The adjacency-list is usually preferred if the graph is sparse (having few edges). • The adjacency-matrix is preferred if the graph is dense (the number of edges is close to the maximal number of edges). If |E| ≈ |V|2 the graph is dense If |E| ≈ |V| the graph is sparse Dense Graph Sparse Graph Figure: Dense and Sparse Graph 12