SlideShare a Scribd company logo
1 of 33
Data StructuresMphil - GrAPHS Jibrael Jos : Oct 2009
Graph Operation Graph Structure Adjacency List Create Graph Insert Vertex Insert Arc Retrieve Vertex Avoid Taking Printout : Use RTF Outline in case needed 2 Agenda
Operations (6) Add Vertex Delete Vertex Add Edge Delete Edge Find Vertex Traverse Graph Please Do Not Take Printout : Use RTF Outline in case needed 3
Graph – Structure  (2,6,2) graphHead Count First graphArc Dest nextArc Please Do Not Take Printout : Use RTF Outline in case needed 4 ,[object Object]
nextVertex
Data
inDegree
outDegree
Processed
Arc,[object Object]
Create Adjacency List Please Do Not Take Printout : Use RTF Outline in case needed 6 Delhi Nagpur Mumbai Kolkatta Hyderabad Chennai Bangalore
Please Do Not Take Printout : Use RTF Outline in case needed 7 6 Adjacency List 2 2 p 2 2 p 2 1 p 1 1 p 2 3 p 1 1 p Vertex List
createGraph If (mem available)     allocate (newPtr) newPtr->count=0 newPtr->first=null Else newPtr=null Return newPtr Please Do Not Take Printout : Use RTF Outline in case needed 8
insertVertex If (mem Not available)     return -1 allocate (newPtr) Init all 6  Find Insertion Point Empty Graph … at beginning Middle Before First Vertex Please Do Not Take Printout : Use RTF Outline in case needed 9
insertArc If (mem Not available)     return -1 Locate from Locate to Insert New Arc outDegree of from inDegree of to Allocate Set destination of new ptr to “toPtr” Set ptr of from to newPtr (explained in next page) Please Do Not Take Printout : Use RTF Outline in case needed 10
insertArc Find Insertion Point Empty List … at first arc Middle Before First Arc Please Do Not Take Printout : Use RTF Outline in case needed 11
Retrieve Vertex If Graph -> first null        return  -2 Else set curr to first        loop till you find        if found           set data out            return 1        else            return -2 Please Do Not Take Printout : Use RTF Outline in case needed 12
Minimum Spanning Tree Shortest Path Avoid Taking Printout : Use RTF Outline in case needed 13 Agenda
Walk Thru Minimum Spanning Tree Prim / Dijikstra (pg 579) Kruskal Shortest Path Algorithm Please Do Not Take Printout : Use RTF Outline in case needed 14
Minimum ST Please Do Not Take Printout : Use RTF Outline in case needed 15 Delhi: 5 or 3 D,N: 5,3,or 2 D,N,H:5,3,3 D,N,H,M:4,3 D,N,H,M,B:3 D,N,H,M,B,C:5 D,N,H,M,B,C,K Delhi 5 3 Nagpur 3 Mumbai Kolkata 2 Hyderabad 5 4 3 3 Chennai Bangalore
Minimum ST Please Do Not Take Printout : Use RTF Outline in case needed 16 Start With Mumbai Delhi 5 3 Nagpur 3 Mumbai Kolkata 2 Hyderabad 5 4 3 3 Chennai Bangalore
Network MST– Structure  (2,7,4) graphHead Count First graphArc Dest inTree Weight nextEdge Please Do Not Take Printout : Use RTF Outline in case needed 17 ,[object Object]
nextVertex
Data
inDegree
outDegree
inTree
Processed *
Edge,[object Object]
Please Do Not Take Printout : Use RTF Outline in case needed 19 6 Adjacency List 2 2 p 2 2 p 2 1 p 1 1 p 2 3 p 1 1 p Vertex List
Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 20 Delhi : ∞  5 3 Nagpur ∞ 3 Mumbai : ∞ Kolkata ∞ 2 Hyderabad ∞ 5 4 3 3 Chennai ∞ Bangalore ∞
Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 21 Delhi : 0 5 3 Nagpur ∞ 3 Mumbai : ∞ Kolkata ∞ 2 Hyderabad ∞ 5 4 3 3 Chennai ∞ Bangalore ∞
Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 22 Delhi : 0 5 3 Nagpur 3 3 Mumbai : ∞ Kolkata ∞ 2 Hyderabad ∞ 5 4 3 3 Chennai ∞ Bangalore ∞

More Related Content

What's hot

Geographic Information Systems (December - 2018) [IDOL - Revised Course]
Geographic Information Systems (December - 2018) [IDOL - Revised Course]Geographic Information Systems (December - 2018) [IDOL - Revised Course]
Geographic Information Systems (December - 2018) [IDOL - Revised Course]Mumbai B.Sc.IT Study
 
[Question Paper] Data Communication and Network Standards (Revised Course) [J...
[Question Paper] Data Communication and Network Standards (Revised Course) [J...[Question Paper] Data Communication and Network Standards (Revised Course) [J...
[Question Paper] Data Communication and Network Standards (Revised Course) [J...Mumbai B.Sc.IT Study
 
[Question Paper] Web Design and Internet Based Applications (Old Syllabus) [A...
[Question Paper] Web Design and Internet Based Applications (Old Syllabus) [A...[Question Paper] Web Design and Internet Based Applications (Old Syllabus) [A...
[Question Paper] Web Design and Internet Based Applications (Old Syllabus) [A...Mumbai B.Sc.IT Study
 
[Question Paper] Web Technology (Revised Course) [October / 2016]
[Question Paper] Web Technology (Revised Course) [October / 2016][Question Paper] Web Technology (Revised Course) [October / 2016]
[Question Paper] Web Technology (Revised Course) [October / 2016]Mumbai B.Sc.IT Study
 
Internet Technology (April – 2013) [Revised Syllabus | Question Paper]
Internet Technology (April  – 2013) [Revised Syllabus | Question Paper]Internet Technology (April  – 2013) [Revised Syllabus | Question Paper]
Internet Technology (April – 2013) [Revised Syllabus | Question Paper]Mumbai B.Sc.IT Study
 
Geographic Information Systems (April – 2013) [Question Paper | IDOL: Revised...
Geographic Information Systems (April – 2013) [Question Paper | IDOL: Revised...Geographic Information Systems (April – 2013) [Question Paper | IDOL: Revised...
Geographic Information Systems (April – 2013) [Question Paper | IDOL: Revised...Mumbai B.Sc.IT Study
 
Geographic Information System (April – 2014) [60:40 Pattern | Question Paper]
Geographic Information System (April – 2014) [60:40 Pattern | Question Paper]Geographic Information System (April – 2014) [60:40 Pattern | Question Paper]
Geographic Information System (April – 2014) [60:40 Pattern | Question Paper]Mumbai B.Sc.IT Study
 
Internet Technologies (October – 2016) [Question Paper | IDOL: Revised Course]
Internet Technologies (October – 2016) [Question Paper | IDOL: Revised Course]Internet Technologies (October – 2016) [Question Paper | IDOL: Revised Course]
Internet Technologies (October – 2016) [Question Paper | IDOL: Revised Course]Mumbai B.Sc.IT Study
 
WF ED 540, Class Meeting 8, 15 October 2015, Plan for Meeting
WF ED 540, Class Meeting 8, 15 October 2015, Plan for MeetingWF ED 540, Class Meeting 8, 15 October 2015, Plan for Meeting
WF ED 540, Class Meeting 8, 15 October 2015, Plan for MeetingPenn State University
 
Free video lectures for mba
Free video lectures for mbaFree video lectures for mba
Free video lectures for mbaEdhole.com
 
ASP.NET With C# (May – 2018) [IDOL: Revised Course | Question Paper]
ASP.NET With C# (May – 2018) [IDOL: Revised Course | Question Paper]ASP.NET With C# (May – 2018) [IDOL: Revised Course | Question Paper]
ASP.NET With C# (May – 2018) [IDOL: Revised Course | Question Paper]Mumbai B.Sc.IT Study
 
THoSP: an Algorithm for Nesting Property Graphs
THoSP: an Algorithm for Nesting Property GraphsTHoSP: an Algorithm for Nesting Property Graphs
THoSP: an Algorithm for Nesting Property GraphsGiacomo Bergami
 
SIGMOD 2013 - Patricia's talk on "Value invention for Data Exchange"
SIGMOD 2013 - Patricia's talk on "Value invention for Data Exchange"SIGMOD 2013 - Patricia's talk on "Value invention for Data Exchange"
SIGMOD 2013 - Patricia's talk on "Value invention for Data Exchange"Boris Glavic
 
Eighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateEighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateopenCypher
 
Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Java and Data Structure (September - 2013) [Revised Course | Question Paper]Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Java and Data Structure (September - 2013) [Revised Course | Question Paper]Mumbai B.Sc.IT Study
 
[Question Paper] Microprocessor and Microcontrollers (Revised Course) [Octobe...
[Question Paper] Microprocessor and Microcontrollers (Revised Course) [Octobe...[Question Paper] Microprocessor and Microcontrollers (Revised Course) [Octobe...
[Question Paper] Microprocessor and Microcontrollers (Revised Course) [Octobe...Mumbai B.Sc.IT Study
 

What's hot (16)

Geographic Information Systems (December - 2018) [IDOL - Revised Course]
Geographic Information Systems (December - 2018) [IDOL - Revised Course]Geographic Information Systems (December - 2018) [IDOL - Revised Course]
Geographic Information Systems (December - 2018) [IDOL - Revised Course]
 
[Question Paper] Data Communication and Network Standards (Revised Course) [J...
[Question Paper] Data Communication and Network Standards (Revised Course) [J...[Question Paper] Data Communication and Network Standards (Revised Course) [J...
[Question Paper] Data Communication and Network Standards (Revised Course) [J...
 
[Question Paper] Web Design and Internet Based Applications (Old Syllabus) [A...
[Question Paper] Web Design and Internet Based Applications (Old Syllabus) [A...[Question Paper] Web Design and Internet Based Applications (Old Syllabus) [A...
[Question Paper] Web Design and Internet Based Applications (Old Syllabus) [A...
 
[Question Paper] Web Technology (Revised Course) [October / 2016]
[Question Paper] Web Technology (Revised Course) [October / 2016][Question Paper] Web Technology (Revised Course) [October / 2016]
[Question Paper] Web Technology (Revised Course) [October / 2016]
 
Internet Technology (April – 2013) [Revised Syllabus | Question Paper]
Internet Technology (April  – 2013) [Revised Syllabus | Question Paper]Internet Technology (April  – 2013) [Revised Syllabus | Question Paper]
Internet Technology (April – 2013) [Revised Syllabus | Question Paper]
 
Geographic Information Systems (April – 2013) [Question Paper | IDOL: Revised...
Geographic Information Systems (April – 2013) [Question Paper | IDOL: Revised...Geographic Information Systems (April – 2013) [Question Paper | IDOL: Revised...
Geographic Information Systems (April – 2013) [Question Paper | IDOL: Revised...
 
Geographic Information System (April – 2014) [60:40 Pattern | Question Paper]
Geographic Information System (April – 2014) [60:40 Pattern | Question Paper]Geographic Information System (April – 2014) [60:40 Pattern | Question Paper]
Geographic Information System (April – 2014) [60:40 Pattern | Question Paper]
 
Internet Technologies (October – 2016) [Question Paper | IDOL: Revised Course]
Internet Technologies (October – 2016) [Question Paper | IDOL: Revised Course]Internet Technologies (October – 2016) [Question Paper | IDOL: Revised Course]
Internet Technologies (October – 2016) [Question Paper | IDOL: Revised Course]
 
WF ED 540, Class Meeting 8, 15 October 2015, Plan for Meeting
WF ED 540, Class Meeting 8, 15 October 2015, Plan for MeetingWF ED 540, Class Meeting 8, 15 October 2015, Plan for Meeting
WF ED 540, Class Meeting 8, 15 October 2015, Plan for Meeting
 
Free video lectures for mba
Free video lectures for mbaFree video lectures for mba
Free video lectures for mba
 
ASP.NET With C# (May – 2018) [IDOL: Revised Course | Question Paper]
ASP.NET With C# (May – 2018) [IDOL: Revised Course | Question Paper]ASP.NET With C# (May – 2018) [IDOL: Revised Course | Question Paper]
ASP.NET With C# (May – 2018) [IDOL: Revised Course | Question Paper]
 
THoSP: an Algorithm for Nesting Property Graphs
THoSP: an Algorithm for Nesting Property GraphsTHoSP: an Algorithm for Nesting Property Graphs
THoSP: an Algorithm for Nesting Property Graphs
 
SIGMOD 2013 - Patricia's talk on "Value invention for Data Exchange"
SIGMOD 2013 - Patricia's talk on "Value invention for Data Exchange"SIGMOD 2013 - Patricia's talk on "Value invention for Data Exchange"
SIGMOD 2013 - Patricia's talk on "Value invention for Data Exchange"
 
Eighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateEighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status Update
 
Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Java and Data Structure (September - 2013) [Revised Course | Question Paper]Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Java and Data Structure (September - 2013) [Revised Course | Question Paper]
 
[Question Paper] Microprocessor and Microcontrollers (Revised Course) [Octobe...
[Question Paper] Microprocessor and Microcontrollers (Revised Course) [Octobe...[Question Paper] Microprocessor and Microcontrollers (Revised Course) [Octobe...
[Question Paper] Microprocessor and Microcontrollers (Revised Course) [Octobe...
 

Viewers also liked

Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structuresSavit Chandra
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in cPrabhu Govind
 
Data structure computer graphs
Data structure computer graphsData structure computer graphs
Data structure computer graphsKumar
 
Matrix Representation Of Graph
Matrix Representation Of GraphMatrix Representation Of Graph
Matrix Representation Of GraphAbhishek Pachisia
 

Viewers also liked (6)

Graphss
GraphssGraphss
Graphss
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
 
Data structure computer graphs
Data structure computer graphsData structure computer graphs
Data structure computer graphs
 
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
 
Matrix Representation Of Graph
Matrix Representation Of GraphMatrix Representation Of Graph
Matrix Representation Of Graph
 

More from Jibrael Jos

Followership, A Leadership Workshop
Followership, A Leadership WorkshopFollowership, A Leadership Workshop
Followership, A Leadership WorkshopJibrael Jos
 
Steven Covey 7 Habits of Highly Effective People
Steven Covey 7 Habits of Highly Effective PeopleSteven Covey 7 Habits of Highly Effective People
Steven Covey 7 Habits of Highly Effective PeopleJibrael Jos
 
Big Bang to DNA , Relatively Speaking
Big Bang to DNA , Relatively SpeakingBig Bang to DNA , Relatively Speaking
Big Bang to DNA , Relatively SpeakingJibrael Jos
 
Data Structures : Sort Explained
Data Structures : Sort ExplainedData Structures : Sort Explained
Data Structures : Sort ExplainedJibrael Jos
 
Data Structures : Sorting
Data Structures : SortingData Structures : Sorting
Data Structures : SortingJibrael Jos
 
BTree, Data Structures
BTree, Data StructuresBTree, Data Structures
BTree, Data StructuresJibrael Jos
 
Data Structures : AVL Trees
Data Structures : AVL TreesData Structures : AVL Trees
Data Structures : AVL TreesJibrael Jos
 

More from Jibrael Jos (7)

Followership, A Leadership Workshop
Followership, A Leadership WorkshopFollowership, A Leadership Workshop
Followership, A Leadership Workshop
 
Steven Covey 7 Habits of Highly Effective People
Steven Covey 7 Habits of Highly Effective PeopleSteven Covey 7 Habits of Highly Effective People
Steven Covey 7 Habits of Highly Effective People
 
Big Bang to DNA , Relatively Speaking
Big Bang to DNA , Relatively SpeakingBig Bang to DNA , Relatively Speaking
Big Bang to DNA , Relatively Speaking
 
Data Structures : Sort Explained
Data Structures : Sort ExplainedData Structures : Sort Explained
Data Structures : Sort Explained
 
Data Structures : Sorting
Data Structures : SortingData Structures : Sorting
Data Structures : Sorting
 
BTree, Data Structures
BTree, Data StructuresBTree, Data Structures
BTree, Data Structures
 
Data Structures : AVL Trees
Data Structures : AVL TreesData Structures : AVL Trees
Data Structures : AVL Trees
 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

Data Structures, Graphs

  • 1. Data StructuresMphil - GrAPHS Jibrael Jos : Oct 2009
  • 2. Graph Operation Graph Structure Adjacency List Create Graph Insert Vertex Insert Arc Retrieve Vertex Avoid Taking Printout : Use RTF Outline in case needed 2 Agenda
  • 3. Operations (6) Add Vertex Delete Vertex Add Edge Delete Edge Find Vertex Traverse Graph Please Do Not Take Printout : Use RTF Outline in case needed 3
  • 4.
  • 10.
  • 11. Create Adjacency List Please Do Not Take Printout : Use RTF Outline in case needed 6 Delhi Nagpur Mumbai Kolkatta Hyderabad Chennai Bangalore
  • 12. Please Do Not Take Printout : Use RTF Outline in case needed 7 6 Adjacency List 2 2 p 2 2 p 2 1 p 1 1 p 2 3 p 1 1 p Vertex List
  • 13. createGraph If (mem available) allocate (newPtr) newPtr->count=0 newPtr->first=null Else newPtr=null Return newPtr Please Do Not Take Printout : Use RTF Outline in case needed 8
  • 14. insertVertex If (mem Not available) return -1 allocate (newPtr) Init all 6 Find Insertion Point Empty Graph … at beginning Middle Before First Vertex Please Do Not Take Printout : Use RTF Outline in case needed 9
  • 15. insertArc If (mem Not available) return -1 Locate from Locate to Insert New Arc outDegree of from inDegree of to Allocate Set destination of new ptr to “toPtr” Set ptr of from to newPtr (explained in next page) Please Do Not Take Printout : Use RTF Outline in case needed 10
  • 16. insertArc Find Insertion Point Empty List … at first arc Middle Before First Arc Please Do Not Take Printout : Use RTF Outline in case needed 11
  • 17. Retrieve Vertex If Graph -> first null return -2 Else set curr to first loop till you find if found set data out return 1 else return -2 Please Do Not Take Printout : Use RTF Outline in case needed 12
  • 18. Minimum Spanning Tree Shortest Path Avoid Taking Printout : Use RTF Outline in case needed 13 Agenda
  • 19. Walk Thru Minimum Spanning Tree Prim / Dijikstra (pg 579) Kruskal Shortest Path Algorithm Please Do Not Take Printout : Use RTF Outline in case needed 14
  • 20. Minimum ST Please Do Not Take Printout : Use RTF Outline in case needed 15 Delhi: 5 or 3 D,N: 5,3,or 2 D,N,H:5,3,3 D,N,H,M:4,3 D,N,H,M,B:3 D,N,H,M,B,C:5 D,N,H,M,B,C,K Delhi 5 3 Nagpur 3 Mumbai Kolkata 2 Hyderabad 5 4 3 3 Chennai Bangalore
  • 21. Minimum ST Please Do Not Take Printout : Use RTF Outline in case needed 16 Start With Mumbai Delhi 5 3 Nagpur 3 Mumbai Kolkata 2 Hyderabad 5 4 3 3 Chennai Bangalore
  • 22.
  • 24. Data
  • 29.
  • 30. Please Do Not Take Printout : Use RTF Outline in case needed 19 6 Adjacency List 2 2 p 2 2 p 2 1 p 1 1 p 2 3 p 1 1 p Vertex List
  • 31. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 20 Delhi : ∞ 5 3 Nagpur ∞ 3 Mumbai : ∞ Kolkata ∞ 2 Hyderabad ∞ 5 4 3 3 Chennai ∞ Bangalore ∞
  • 32. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 21 Delhi : 0 5 3 Nagpur ∞ 3 Mumbai : ∞ Kolkata ∞ 2 Hyderabad ∞ 5 4 3 3 Chennai ∞ Bangalore ∞
  • 33. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 22 Delhi : 0 5 3 Nagpur 3 3 Mumbai : ∞ Kolkata ∞ 2 Hyderabad ∞ 5 4 3 3 Chennai ∞ Bangalore ∞
  • 34. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 23 Delhi : 0 5 3 5 Nagpur 3 3 Mumbai : ∞ Kolkata ∞ 6 2 5 Hyderabad ∞ 5 4 3 3 Chennai ∞ Bangalore ∞
  • 35. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 24 Delhi : 0 5 3 Nagpur 3 3 Mumbai : 5 Kolkata ∞ 2 Hyderabad ∞ 5 4 3 3 Chennai ∞ Bangalore ∞
  • 36. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 25 Delhi : 0 5 3 Nagpur 3 3 Mumbai : 5 Kolkata ∞ 2 5 Hyderabad ∞ 5 4 3 3 9 Chennai ∞ Bangalore ∞
  • 37. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 26 Delhi : 0 5 3 Nagpur 3 3 Mumbai : 5 Kolkata ∞ 2 Hyderabad 5 5 4 3 3 Chennai ∞ Bangalore ∞
  • 38. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 27 Delhi : 0 5 3 Nagpur 3 3 Mumbai : 5 Kolkata ∞ 2 Hyderabad 5 5 4 3 8 3 9 Chennai ∞ Bangalore ∞
  • 39. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 28 Delhi : 0 5 3 Nagpur 3 3 Mumbai : 5 Kolkata ∞ 2 Hyderabad 5 5 4 3 3 Chennai ∞ Bangalore 8
  • 40. Shortest Path Please Do Not Take Printout : Use RTF Outline in case needed 29 What if we start from Hyderabad? Delhi : 0 5 3 Nagpur 3 3 Mumbai : 5 Kolkata 16 2 Hyderabad 5 5 4 3 3 Chennai 11 Bangalore 8
  • 41.
  • 43. Data
  • 49.
  • 50. M S Tree (pg 583) Loop (In order Vertex) Loop (Edge to initialise) Loop Till Tree Complete Loop (to find next Vertex) Loop (locate smallest path) Test for shortest Path Set inTree (2 places) , pathLength (dest) Please Do Not Take Printout : Use RTF Outline in case needed 32
  • 51. Reference (PS: starting vertex only) http://en.wikipedia.org/wiki/Graph_theory http://en.wikipedia.org/wiki/Dijkstra’s_algorithm Furzon(for those who have no earlier graph background): Chapter 12 Please Do Not Take Printout : Use RTF Outline in case needed 33 Action Item