SlideShare a Scribd company logo
1

GRAPH
INTRODUCTION
Introduced in 1736

Leonhard Euler
Solved “Konigsberg Bridge Problem”

2

Eulerian Circuit or Euler Tour
KONIGSBERG BRIDGE
PROBLEM

3

The problem was to find a walk through the city that would
cross each bridge once and only once. The islands could not
be reached by any route other than the bridges, and every
bridge must have been crossed completely every time; one
could not walk halfway onto the bridge and then turn around
and later cross the other half from the other side. The walk
need to start and end at the same spot.
4

KONIGSBERG BRIDGE
PROBLEM
5

DESIGN OF SOLUTION
6

CLASS TASK
7

SOLUTION
CONCLUSION

8

Eularian circuit exists if,
and only if, the graph is
connected, and there
are no nodes of odd
degree at all.
BASIC TERMINOLOGY
Graph : Two sets V(G) & E(G)

Undirected Graph

(u,v)

Directed Graph

<u,v>

Self Edges
Multigraph
No. of edges = n(n-1)/2(undirected)

9

No. of edges = n(n-1) (directed)
BASIC TERMINOLOGY
Adjacent Vertices

Subgraph
Path
Length of Path
Simple Path : all vertices are distinct except first & last

10

Cycle
BASIC TERMINOLOGY
Connected Vertices

Connected graph
Connected Components : maximal connected subgraph
Acyclic Graph
Strongly Connected

11

Strongly Connected Components
BASIC TERMINOLOGY
Degree

In-degree
Out-degree

12

Weighted Edges
GRAPH
REPRESENTATION
Adjacency Matrix

13

Adjacency List
OPERATIONS ON
GRAPH
Depth-First Search

Breadth-First Search

Connected Components

14

Shortest Path Algorithm
DEPTH-FIRST SEARCH
Void Graph ::DFS( )
Visited = new boolean[n];
For(int I=0;I<n;I++) visited [I] = false;
DFS(0);
Delete [] visited;
Void Graph ::DFS(const int v)
visited [v] = true;
for( each vertex w adjacent to v)
if(! Visited [w]) DFS(w);

15

•
•
•
•
BREADTH-FIRST SEARCH
Void Graph ::BFS(int v)
• Visited = new boolean[n];
• For(int I=0; I<n; I++) visited [I] = false;
• Visited [v] = true;
• Queue<int> q;
• Q.insert(v);
• While(!q.IsEmpty())
• V= *q.delete(v);
• For(all vertices w adjacent to v)
• If(!visited [w])
• q.Insert(w);
• Visited [w] = true;

16

• Delete [] visited;
CONNECTED COMPONENT
Void Graph::Components( )
• Visited = new boolean [n];
• For(int I = 0;I < n; I++) visited [I] = false;
• For(I=0; I < n; I++)
• If (! Visited [I])
• DFS (I);
• OutputNewComponent();

17

• Delete [ ] visited;
SHORTEST PATH
Void Graph::ShortestPath(int n, int v)
• For(int I=0; I<n; I++)
{s[I] =false;dist[I]=length[v][I];}
• S[v] = true;
• Dist[v] = 0;
• For(I=0; I<=n-2; I++)

18

• Int u=choose(n);
• S[u] = true;
• For(int w=0; w<n; w++)
• If(!s[w])
• If(dist[u] + length[u][w] < dist[w])
• Dist[w] = dist[u] + length[u][w];
EXAMPLE
1

2

3

4

0

0

5

10

∞

∞

1

∞

0

3

2

9

2

∞

∞

0

6

∞

3

∞

∞

∞

0

4

4

∞

∞

∞

∞

0

19

0

More Related Content

Similar to Graph

2.5 dfs & bfs
2.5 dfs & bfs2.5 dfs & bfs
2.5 dfs & bfs
Krish_ver2
 
Koningsberg bridge problem
Koningsberg  bridge  problemKoningsberg  bridge  problem
Koningsberg bridge problem
Sudiksha Joshi
 
BFS
BFSBFS
Graph Traversal Algorithm
Graph Traversal AlgorithmGraph Traversal Algorithm
Graph Traversal Algorithm
jyothimonc
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
Savit Chandra
 
Euler graph
Euler graphEuler graph
Euler graph
AAQIB PARREY
 
B.tech admission in india
B.tech admission in indiaB.tech admission in india
B.tech admission in india
Edhole.com
 
Graph ds
Graph dsGraph ds
Graphs
GraphsGraphs
Graph theory
Graph theoryGraph theory
Graph theory
manikanta361
 
14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath
SSE_AndyLi
 
Graps 2
Graps 2Graps 2
Distruct week 15 graphs theory (updated)
Distruct week 15 graphs theory (updated)Distruct week 15 graphs theory (updated)
Distruct week 15 graphs theory (updated)
Robert Almazan
 
Unit 9 graph
Unit   9 graphUnit   9 graph
Unit 9 graph
Dabbal Singh Mahara
 
Unit 2: All
Unit 2: AllUnit 2: All
Unit 2: All
Hector Zenil
 
distructweek15graphstheoryupdated-160227143444.pdf
distructweek15graphstheoryupdated-160227143444.pdfdistructweek15graphstheoryupdated-160227143444.pdf
distructweek15graphstheoryupdated-160227143444.pdf
ansariparveen06
 
Unit ix graph
Unit   ix    graph Unit   ix    graph
Unit ix graph
Tribhuvan University
 
FADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdfFADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdf
Yelah1
 
topological_sort_strongly Connected Components
topological_sort_strongly Connected Componentstopological_sort_strongly Connected Components
topological_sort_strongly Connected Components
JahidulIslam47153
 
Elementary Graph Algo.ppt
Elementary Graph Algo.pptElementary Graph Algo.ppt
Elementary Graph Algo.ppt
SazidHossain9
 

Similar to Graph (20)

2.5 dfs & bfs
2.5 dfs & bfs2.5 dfs & bfs
2.5 dfs & bfs
 
Koningsberg bridge problem
Koningsberg  bridge  problemKoningsberg  bridge  problem
Koningsberg bridge problem
 
BFS
BFSBFS
BFS
 
Graph Traversal Algorithm
Graph Traversal AlgorithmGraph Traversal Algorithm
Graph Traversal Algorithm
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
 
Euler graph
Euler graphEuler graph
Euler graph
 
B.tech admission in india
B.tech admission in indiaB.tech admission in india
B.tech admission in india
 
Graph ds
Graph dsGraph ds
Graph ds
 
Graphs
GraphsGraphs
Graphs
 
Graph theory
Graph theoryGraph theory
Graph theory
 
14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath
 
Graps 2
Graps 2Graps 2
Graps 2
 
Distruct week 15 graphs theory (updated)
Distruct week 15 graphs theory (updated)Distruct week 15 graphs theory (updated)
Distruct week 15 graphs theory (updated)
 
Unit 9 graph
Unit   9 graphUnit   9 graph
Unit 9 graph
 
Unit 2: All
Unit 2: AllUnit 2: All
Unit 2: All
 
distructweek15graphstheoryupdated-160227143444.pdf
distructweek15graphstheoryupdated-160227143444.pdfdistructweek15graphstheoryupdated-160227143444.pdf
distructweek15graphstheoryupdated-160227143444.pdf
 
Unit ix graph
Unit   ix    graph Unit   ix    graph
Unit ix graph
 
FADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdfFADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdf
 
topological_sort_strongly Connected Components
topological_sort_strongly Connected Componentstopological_sort_strongly Connected Components
topological_sort_strongly Connected Components
 
Elementary Graph Algo.ppt
Elementary Graph Algo.pptElementary Graph Algo.ppt
Elementary Graph Algo.ppt
 

Recently uploaded

GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 

Recently uploaded (20)

GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 

Graph