際際滷

際際滷Share a Scribd company logo
Introduction to Graph Theory

     Eulerian path Algorithm
Graph theory
 A graph is used in mathematics and computer science
  to represent pairwise relations between objects.
 It is represented as a collection of nodes and edges.
  The edges connect the nodes.
 Each node or/and edge can have certain values or
  names assigned to it.
 Two nodes are called neighbors if they are connected
  with an edge.
 Two edges are connected if they have a common node.
 simple graph:
Example of a graph:




In this example the nodes are the cities in Macedonia and the
edges are the roads between a pair of cities.
Definition of the Eulerian path
                 problem
 Urban definition:
    Given a drawing on a piece of paper, try to cross all the lines
     with a pen such that the pen doesnt leave the paper and you
     mustnt cross a line more than once.
 Professional definition:
    Given a graph G, find a sequence of connected edges S such
     that every edge of G is found in S.
 Try solving:
The Algorithm
   Step 1: we first have to input the graph, we will call the graph G.
   Step 2: next we have to check if G is valid. If G is not valid, no solution exists and stop the algorithm.
       How to check if G is valid:
             First we have to determine the number of neighboring nodes to every node of G, we will keep
                this numbers in the sequence X.
             Than we count how many odd numbers are there are in X, and we will call this number N.
             If N = 0 or N = 2 the graph is valid, else the graph is not valid.
   Step 3: next we have to find a starting node, we will name this node W.
       if N = 0 than set W to a random node
       If N = 2 than set W to a node with an odd number of neighbors
   Step 4: define a stack S and push W onto S, also define a sequence of nodes P, P will contain the eulerian
    path solution to G.
   Step 5: while S is nonempty repeat the following steps:
       if W has at least one neighbor
             Set O to the nearest node to W
             Disconnect O from W
             Set W to O
             Go to step 5
       Else add W to P, set W to the top of S, Pop the first element from S
   Step 5: print P and stop the algorithm.
                                                                                      e.g. graph
Ad

Recommended

Introduction to Graph Theory
Introduction to Graph Theory
Kazi Md. Saidul
Algebra I 1
Algebra I 1
iriaprofe
Data Structure : Graph and Graph Traversing
Data Structure : Graph and Graph Traversing
Vikas Chandwani
6.6 Graphing Inequalities In Two Variables
6.6 Graphing Inequalities In Two Variables
guestd1dc2e
Skiena algorithm 2007 lecture10 graph data strctures
Skiena algorithm 2007 lecture10 graph data strctures
zukun
Eulers formula
Eulers formula
Rahul Sharma
Graph in data structure
Graph in data structure
Abrish06
Functions
Functions
Siyavula
Graph (Data structure)
Graph (Data structure)
shamiur rahman
Analytical geometry
Analytical geometry
Siyavula
Graphing inequalities in two variables
Graphing inequalities in two variables
Jessica Garcia
5.1 Finding Slope
5.1 Finding Slope
guest7985b1
Finding slope
Finding slope
kjmonopoly7311
Graphs in c language
Graphs in c language
SARITHA REDDY
Graph
Graph
WinNie Sjr
Can you trust the internet? An introduction to graph theory, computational co...
Can you trust the internet? An introduction to graph theory, computational co...
Denise Gosnell, Ph.D.
Graph theory
Graph theory
Shubham Jain
Graph
Graph
Dr Sandeep Kumar Poonia
Graphs in data structure
Graphs in data structure
hamza javed
6. Graphs
6. Graphs
Mandeep Singh
Per5 sequences
Per5 sequences
Evert Sandye Taasiringan
Data structure - Graph
Data structure - Graph
Madhu Bala
Math real life examples
Math real life examples
student
Discount
Discount
peabody6
Graphing Linear Inequalities
Graphing Linear Inequalities
inderjyot
Sequences & series
Sequences & series
Thabani Masoka
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
Muhammad Hammad Waseem
FLEURYS algorithm graph theory presentation.pptx
FLEURYS algorithm graph theory presentation.pptx
mehnazakhtar980
FADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdf
Yelah1
14. GRAPH in data structures and algorithm.ppt
14. GRAPH in data structures and algorithm.ppt
saurabhthege

More Related Content

What's hot (19)

Graph (Data structure)
Graph (Data structure)
shamiur rahman
Analytical geometry
Analytical geometry
Siyavula
Graphing inequalities in two variables
Graphing inequalities in two variables
Jessica Garcia
5.1 Finding Slope
5.1 Finding Slope
guest7985b1
Finding slope
Finding slope
kjmonopoly7311
Graphs in c language
Graphs in c language
SARITHA REDDY
Graph
Graph
WinNie Sjr
Can you trust the internet? An introduction to graph theory, computational co...
Can you trust the internet? An introduction to graph theory, computational co...
Denise Gosnell, Ph.D.
Graph theory
Graph theory
Shubham Jain
Graph
Graph
Dr Sandeep Kumar Poonia
Graphs in data structure
Graphs in data structure
hamza javed
6. Graphs
6. Graphs
Mandeep Singh
Per5 sequences
Per5 sequences
Evert Sandye Taasiringan
Data structure - Graph
Data structure - Graph
Madhu Bala
Math real life examples
Math real life examples
student
Discount
Discount
peabody6
Graphing Linear Inequalities
Graphing Linear Inequalities
inderjyot
Sequences & series
Sequences & series
Thabani Masoka
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
Muhammad Hammad Waseem
Graph (Data structure)
Graph (Data structure)
shamiur rahman
Analytical geometry
Analytical geometry
Siyavula
Graphing inequalities in two variables
Graphing inequalities in two variables
Jessica Garcia
5.1 Finding Slope
5.1 Finding Slope
guest7985b1
Graphs in c language
Graphs in c language
SARITHA REDDY
Can you trust the internet? An introduction to graph theory, computational co...
Can you trust the internet? An introduction to graph theory, computational co...
Denise Gosnell, Ph.D.
Graphs in data structure
Graphs in data structure
hamza javed
Data structure - Graph
Data structure - Graph
Madhu Bala
Math real life examples
Math real life examples
student
Discount
Discount
peabody6
Graphing Linear Inequalities
Graphing Linear Inequalities
inderjyot
Sequences & series
Sequences & series
Thabani Masoka
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
Muhammad Hammad Waseem

Similar to Graph theory (20)

FLEURYS algorithm graph theory presentation.pptx
FLEURYS algorithm graph theory presentation.pptx
mehnazakhtar980
FADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdf
Yelah1
14. GRAPH in data structures and algorithm.ppt
14. GRAPH in data structures and algorithm.ppt
saurabhthege
Graph Representation, DFS and BFS Presentation.pptx
Graph Representation, DFS and BFS Presentation.pptx
bashirabdullah789
DATA STRUCTURES.pptx
DATA STRUCTURES.pptx
KENNEDY GITHAIGA
logic.pptx
logic.pptx
KENNEDY GITHAIGA
TREE ADT, TREE TRAVERSALS, BINARY TREE ADT
TREE ADT, TREE TRAVERSALS, BINARY TREE ADT
mohanrajm63
Presentation on Graph
Presentation on Graph
Salim Hosen
Daa chpater 12
Daa chpater 12
B.Kirron Reddi
WEB DEVELOPMET FRONT END WITH ADVANCED RECEAT
WEB DEVELOPMET FRONT END WITH ADVANCED RECEAT
sahadevbkbiet2023
Data structure Graph PPT ( BFS & DFS ) NOTES
Data structure Graph PPT ( BFS & DFS ) NOTES
sahadevbkbiet2023
Chap 6 Graph.ppt
Chap 6 Graph.ppt
shashankbhadouria4
Data Structure of computer science and technology
Data Structure of computer science and technology
bhaskarsai499
Basic Graph Algorithms Vertex (Node): lk
Basic Graph Algorithms Vertex (Node): lk
ymwjd5j8pb
Euler graph
Euler graph
AAQIB PARREY
Depth first traversal(data structure algorithms)
Depth first traversal(data structure algorithms)
bhuvaneshwariA5
Graphs
Graphs
LavanyaJ28
Data structure
Data structure
jagjot singh chopra
Graph theory 1
Graph theory 1
Tech_MX
Fleurys abas abbasli_
Fleurys abas abbasli_
abas1333
FLEURYS algorithm graph theory presentation.pptx
FLEURYS algorithm graph theory presentation.pptx
mehnazakhtar980
FADML 06 PPC Graphs and Traversals.pdf
FADML 06 PPC Graphs and Traversals.pdf
Yelah1
14. GRAPH in data structures and algorithm.ppt
14. GRAPH in data structures and algorithm.ppt
saurabhthege
Graph Representation, DFS and BFS Presentation.pptx
Graph Representation, DFS and BFS Presentation.pptx
bashirabdullah789
TREE ADT, TREE TRAVERSALS, BINARY TREE ADT
TREE ADT, TREE TRAVERSALS, BINARY TREE ADT
mohanrajm63
Presentation on Graph
Presentation on Graph
Salim Hosen
WEB DEVELOPMET FRONT END WITH ADVANCED RECEAT
WEB DEVELOPMET FRONT END WITH ADVANCED RECEAT
sahadevbkbiet2023
Data structure Graph PPT ( BFS & DFS ) NOTES
Data structure Graph PPT ( BFS & DFS ) NOTES
sahadevbkbiet2023
Data Structure of computer science and technology
Data Structure of computer science and technology
bhaskarsai499
Basic Graph Algorithms Vertex (Node): lk
Basic Graph Algorithms Vertex (Node): lk
ymwjd5j8pb
Depth first traversal(data structure algorithms)
Depth first traversal(data structure algorithms)
bhuvaneshwariA5
Graph theory 1
Graph theory 1
Tech_MX
Fleurys abas abbasli_
Fleurys abas abbasli_
abas1333
Ad

More from Kliment Serafimov (10)

Technology used in the Iran-Iraq war
Technology used in the Iran-Iraq war
Kliment Serafimov
IB Physics HL Full lab report on research question: Galileos experiment: mea...
IB Physics HL Full lab report on research question: Galileos experiment: mea...
Kliment Serafimov
弌仂亳舒仍亳亰舒亳舒 亳 舒亰于仂 仆舒 仍亳仆仂舒
弌仂亳舒仍亳亰舒亳舒 亳 舒亰于仂 仆舒 仍亳仆仂舒
Kliment Serafimov
Love and revenge in Emily Bronte's "Wuthering Heights"
Love and revenge in Emily Bronte's "Wuthering Heights"
Kliment Serafimov
弍舒仍舒亟舒 亰舒 仆亠仗仂亰仆舒亳仂
弍舒仍舒亟舒 亰舒 仆亠仗仂亰仆舒亳仂
Kliment Serafimov
Voting should be compulsory in democratic societies
Voting should be compulsory in democratic societies
Kliment Serafimov
Extreme sporten
Kliment Serafimov
Extreme sports
Extreme sports
Kliment Serafimov
Computers and the internet
Computers and the internet
Kliment Serafimov
Computers and the internet
Computers and the internet
Kliment Serafimov
Technology used in the Iran-Iraq war
Technology used in the Iran-Iraq war
Kliment Serafimov
IB Physics HL Full lab report on research question: Galileos experiment: mea...
IB Physics HL Full lab report on research question: Galileos experiment: mea...
Kliment Serafimov
弌仂亳舒仍亳亰舒亳舒 亳 舒亰于仂 仆舒 仍亳仆仂舒
弌仂亳舒仍亳亰舒亳舒 亳 舒亰于仂 仆舒 仍亳仆仂舒
Kliment Serafimov
Love and revenge in Emily Bronte's "Wuthering Heights"
Love and revenge in Emily Bronte's "Wuthering Heights"
Kliment Serafimov
弍舒仍舒亟舒 亰舒 仆亠仗仂亰仆舒亳仂
弍舒仍舒亟舒 亰舒 仆亠仗仂亰仆舒亳仂
Kliment Serafimov
Voting should be compulsory in democratic societies
Voting should be compulsory in democratic societies
Kliment Serafimov
Extreme sporten
Kliment Serafimov
Computers and the internet
Computers and the internet
Kliment Serafimov
Computers and the internet
Computers and the internet
Kliment Serafimov
Ad

Graph theory

  • 1. Introduction to Graph Theory Eulerian path Algorithm
  • 2. Graph theory A graph is used in mathematics and computer science to represent pairwise relations between objects. It is represented as a collection of nodes and edges. The edges connect the nodes. Each node or/and edge can have certain values or names assigned to it. Two nodes are called neighbors if they are connected with an edge. Two edges are connected if they have a common node. simple graph:
  • 3. Example of a graph: In this example the nodes are the cities in Macedonia and the edges are the roads between a pair of cities.
  • 4. Definition of the Eulerian path problem Urban definition: Given a drawing on a piece of paper, try to cross all the lines with a pen such that the pen doesnt leave the paper and you mustnt cross a line more than once. Professional definition: Given a graph G, find a sequence of connected edges S such that every edge of G is found in S. Try solving:
  • 5. The Algorithm Step 1: we first have to input the graph, we will call the graph G. Step 2: next we have to check if G is valid. If G is not valid, no solution exists and stop the algorithm. How to check if G is valid: First we have to determine the number of neighboring nodes to every node of G, we will keep this numbers in the sequence X. Than we count how many odd numbers are there are in X, and we will call this number N. If N = 0 or N = 2 the graph is valid, else the graph is not valid. Step 3: next we have to find a starting node, we will name this node W. if N = 0 than set W to a random node If N = 2 than set W to a node with an odd number of neighbors Step 4: define a stack S and push W onto S, also define a sequence of nodes P, P will contain the eulerian path solution to G. Step 5: while S is nonempty repeat the following steps: if W has at least one neighbor Set O to the nearest node to W Disconnect O from W Set W to O Go to step 5 Else add W to P, set W to the top of S, Pop the first element from S Step 5: print P and stop the algorithm. e.g. graph