SlideShare a Scribd company logo
1 of 13
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

Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]Muhammad Hammad Waseem
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms HashingManishPrajapati78
 
Lecture 3 RE NFA DFA
Lecture 3   RE NFA DFA Lecture 3   RE NFA DFA
Lecture 3 RE NFA DFA Rebaz Najeeb
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHPKamal Acharya
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structureAbrish06
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMSkoolkampus
 
Data Structure and Algorithms Heaps and Trees
Data Structure and Algorithms Heaps and TreesData Structure and Algorithms Heaps and Trees
Data Structure and Algorithms Heaps and TreesManishPrajapati78
 
Discrete Mathematics Lecture Notes
Discrete Mathematics Lecture NotesDiscrete Mathematics Lecture Notes
Discrete Mathematics Lecture NotesFellowBuddy.com
 
A Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing NetworkA Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing NetworkShethwala Ridhvesh
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 

What's hot (20)

Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
 
Lecture 3 RE NFA DFA
Lecture 3   RE NFA DFA Lecture 3   RE NFA DFA
Lecture 3 RE NFA DFA
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
Merge sort
Merge sortMerge sort
Merge sort
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHP
 
Strongly connected components
Strongly connected componentsStrongly connected components
Strongly connected components
 
Graph-theory.ppt
Graph-theory.pptGraph-theory.ppt
Graph-theory.ppt
 
Red Black Tree Insertion & Deletion
Red Black Tree Insertion & DeletionRed Black Tree Insertion & Deletion
Red Black Tree Insertion & Deletion
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
Stack
StackStack
Stack
 
Fixed point scaling
Fixed point scalingFixed point scaling
Fixed point scaling
 
Insertion Sorting
Insertion SortingInsertion Sorting
Insertion Sorting
 
Pop operation
Pop operationPop operation
Pop operation
 
Data Structure and Algorithms Heaps and Trees
Data Structure and Algorithms Heaps and TreesData Structure and Algorithms Heaps and Trees
Data Structure and Algorithms Heaps and Trees
 
Discrete Mathematics Lecture Notes
Discrete Mathematics Lecture NotesDiscrete Mathematics Lecture Notes
Discrete Mathematics Lecture Notes
 
A Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing NetworkA Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing Network
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 

Similar to Basics of graph

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 theory
Graph theoryGraph theory
Graph theory
 
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.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 MethodKhaled 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 microprocessorKhaled 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 ApplicationKhaled Sany
 
Dark and Deep web
Dark and Deep webDark and Deep web
Dark and Deep webKhaled 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

定(购)莫纳什大学毕业证(Monash毕业证)成绩单学位证专业定制
定(购)莫纳什大学毕业证(Monash毕业证)成绩单学位证专业定制定(购)莫纳什大学毕业证(Monash毕业证)成绩单学位证专业定制
定(购)莫纳什大学毕业证(Monash毕业证)成绩单学位证专业定制eqaqen
 
Furniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxFurniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxNikhil Raut
 
TRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptxTRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptxtrose8
 
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in RiyadhIn Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadhahmedjiabur940
 
Edward Boginsky's Trailblazing Contributions to Printing
Edward Boginsky's Trailblazing Contributions to PrintingEdward Boginsky's Trailblazing Contributions to Printing
Edward Boginsky's Trailblazing Contributions to PrintingEdward Boginsky
 
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...drmarathore
 
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...samsungultra782445
 
如何办理(Columbia College毕业证书)纽约市哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(Columbia College毕业证书)纽约市哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(Columbia College毕业证书)纽约市哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(Columbia College毕业证书)纽约市哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证ugzga
 
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证eqaqen
 
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...samsungultra782445
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Websitemark11275
 
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...Amil baba
 
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Spring Summer 26 Colors Trend Book Peclers Paris
Spring Summer 26 Colors Trend Book Peclers ParisSpring Summer 26 Colors Trend Book Peclers Paris
Spring Summer 26 Colors Trend Book Peclers ParisPeclers Paris
 
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样yhavx
 
Morgenbooster: Storytelling in Identity Design
Morgenbooster: Storytelling in Identity DesignMorgenbooster: Storytelling in Identity Design
Morgenbooster: Storytelling in Identity Design1508 A/S
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证wpkuukw
 
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证khuurq8kz
 
Branding in the Psychedelic Landscape Report.pdf
Branding in the Psychedelic Landscape Report.pdfBranding in the Psychedelic Landscape Report.pdf
Branding in the Psychedelic Landscape Report.pdfAlexandra Plesner
 
Academic Portfolio (2017-2021) .pdf
Academic Portfolio (2017-2021)      .pdfAcademic Portfolio (2017-2021)      .pdf
Academic Portfolio (2017-2021) .pdfM. A. Architects
 

Recently uploaded (20)

定(购)莫纳什大学毕业证(Monash毕业证)成绩单学位证专业定制
定(购)莫纳什大学毕业证(Monash毕业证)成绩单学位证专业定制定(购)莫纳什大学毕业证(Monash毕业证)成绩单学位证专业定制
定(购)莫纳什大学毕业证(Monash毕业证)成绩单学位证专业定制
 
Furniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxFurniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptx
 
TRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptxTRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptx
 
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in RiyadhIn Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
In Saudi Arabia Jeddah (+918761049707)) Buy Abortion Pills For Sale in Riyadh
 
Edward Boginsky's Trailblazing Contributions to Printing
Edward Boginsky's Trailblazing Contributions to PrintingEdward Boginsky's Trailblazing Contributions to Printing
Edward Boginsky's Trailblazing Contributions to Printing
 
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
Abortion pills in Kuwait 🚚+966505195917 but home delivery available in Kuwait...
 
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
 
如何办理(Columbia College毕业证书)纽约市哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(Columbia College毕业证书)纽约市哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(Columbia College毕业证书)纽约市哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(Columbia College毕业证书)纽约市哥伦比亚大学毕业证成绩单本科硕士学位证留信学历认证
 
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
 
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Riyadh +966572737505 <> buy cytotec <> unwanted kit Saudi A...
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
 
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
 
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Semarang ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Spring Summer 26 Colors Trend Book Peclers Paris
Spring Summer 26 Colors Trend Book Peclers ParisSpring Summer 26 Colors Trend Book Peclers Paris
Spring Summer 26 Colors Trend Book Peclers Paris
 
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
 
Morgenbooster: Storytelling in Identity Design
Morgenbooster: Storytelling in Identity DesignMorgenbooster: Storytelling in Identity Design
Morgenbooster: Storytelling in Identity Design
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
 
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
一比一原版澳洲堪培拉大学毕业证(UC毕业证书)毕业证成绩单留信认证
 
Branding in the Psychedelic Landscape Report.pdf
Branding in the Psychedelic Landscape Report.pdfBranding in the Psychedelic Landscape Report.pdf
Branding in the Psychedelic Landscape Report.pdf
 
Academic Portfolio (2017-2021) .pdf
Academic Portfolio (2017-2021)      .pdfAcademic Portfolio (2017-2021)      .pdf
Academic Portfolio (2017-2021) .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