SlideShare a Scribd company logo
1 of 1
Download to read offline
An Euler cycle in a directed graph is a cycle in which every edge is visited exactly once. Design
an algorithm to test whether a given direct graph has an Euler cycle or not, and if so, find such a
cycle.
Solution
ALGORITHM
Given a starting vertex , the v0algorithm will first find a cycle C starting and ending at v0 such
that C contains all edges going into and out of v0. This can be performed by a walk in the graph.
As we discover vertices in cycle C, we will create a linked list which contains vertices in order
and such that the list begins and ends in vertex v0. We set the current painter to the head of the
list. We now traverse the list by moving our pointer "current" to successive vertices until we
and a vertex which has an outgoing edge which has not been discovered. (If we reach the end of
the list, then we have already found the Eule cycle ). Suppose we find the vertex, vi, that has an
undiscovered outgoing edge. We then take a walk beginning and ending at vi such that all
undiscovered edges containing vi are contained in the walk. We insert our new linked list into
old linked list in place of vi and more "current" to the new neighbor pointed to the first node
containing vi. We continue this process until we search the final node of the linked list, and the
list will then contains an Euler cycle
Running Time of Euler cycle
The algorithm traverse each edge at most twice, first in a walk and second while traversing the
list to find vertices with outgoing edges. Therefore, the total running time of the algorithm is
O(|E|).

More Related Content

More from Bramansinternational

An increase in population would be represented by a movement fromA.pdf
An increase in population would be represented by a movement fromA.pdfAn increase in population would be represented by a movement fromA.pdf
An increase in population would be represented by a movement fromA.pdfBramansinternational
 
An experiment is performed to compare the average reading scores of .pdf
An experiment is performed to compare the average reading scores of .pdfAn experiment is performed to compare the average reading scores of .pdf
An experiment is performed to compare the average reading scores of .pdfBramansinternational
 
An example of the growth factor in common stock is retaining pr.pdf
An example of the growth factor in common stock is retaining pr.pdfAn example of the growth factor in common stock is retaining pr.pdf
An example of the growth factor in common stock is retaining pr.pdfBramansinternational
 
An experiment is performed where a coin is flipped until the first H.pdf
An experiment is performed where a coin is flipped until the first H.pdfAn experiment is performed where a coin is flipped until the first H.pdf
An experiment is performed where a coin is flipped until the first H.pdfBramansinternational
 
An experiment is conducted to examine the effect of punishment on le.pdf
An experiment is conducted to examine the effect of punishment on le.pdfAn experiment is conducted to examine the effect of punishment on le.pdf
An experiment is conducted to examine the effect of punishment on le.pdfBramansinternational
 
An epidemiologist found five cases ofSolution Epidemiology is .pdf
An epidemiologist found five cases ofSolution Epidemiology is .pdfAn epidemiologist found five cases ofSolution Epidemiology is .pdf
An epidemiologist found five cases ofSolution Epidemiology is .pdfBramansinternational
 
An enterprise recently reported an EBITDA of 8million and net income.pdf
An enterprise recently reported an EBITDA of 8million and net income.pdfAn enterprise recently reported an EBITDA of 8million and net income.pdf
An enterprise recently reported an EBITDA of 8million and net income.pdfBramansinternational
 
An experiment consists of selecting an integer X at random from {1,..pdf
An experiment consists of selecting an integer X at random from {1,..pdfAn experiment consists of selecting an integer X at random from {1,..pdf
An experiment consists of selecting an integer X at random from {1,..pdfBramansinternational
 
An entomologist writes an article in a scientific journal which clai.pdf
An entomologist writes an article in a scientific journal which clai.pdfAn entomologist writes an article in a scientific journal which clai.pdf
An entomologist writes an article in a scientific journal which clai.pdfBramansinternational
 
An employer must hire 3 people from a list of 12 applicants. In how .pdf
An employer must hire 3 people from a list of 12 applicants. In how .pdfAn employer must hire 3 people from a list of 12 applicants. In how .pdf
An employer must hire 3 people from a list of 12 applicants. In how .pdfBramansinternational
 
An employer must hire 2 people from a list of 13 applicants. In how .pdf
An employer must hire 2 people from a list of 13 applicants. In how .pdfAn employer must hire 2 people from a list of 13 applicants. In how .pdf
An employer must hire 2 people from a list of 13 applicants. In how .pdfBramansinternational
 

More from Bramansinternational (11)

An increase in population would be represented by a movement fromA.pdf
An increase in population would be represented by a movement fromA.pdfAn increase in population would be represented by a movement fromA.pdf
An increase in population would be represented by a movement fromA.pdf
 
An experiment is performed to compare the average reading scores of .pdf
An experiment is performed to compare the average reading scores of .pdfAn experiment is performed to compare the average reading scores of .pdf
An experiment is performed to compare the average reading scores of .pdf
 
An example of the growth factor in common stock is retaining pr.pdf
An example of the growth factor in common stock is retaining pr.pdfAn example of the growth factor in common stock is retaining pr.pdf
An example of the growth factor in common stock is retaining pr.pdf
 
An experiment is performed where a coin is flipped until the first H.pdf
An experiment is performed where a coin is flipped until the first H.pdfAn experiment is performed where a coin is flipped until the first H.pdf
An experiment is performed where a coin is flipped until the first H.pdf
 
An experiment is conducted to examine the effect of punishment on le.pdf
An experiment is conducted to examine the effect of punishment on le.pdfAn experiment is conducted to examine the effect of punishment on le.pdf
An experiment is conducted to examine the effect of punishment on le.pdf
 
An epidemiologist found five cases ofSolution Epidemiology is .pdf
An epidemiologist found five cases ofSolution Epidemiology is .pdfAn epidemiologist found five cases ofSolution Epidemiology is .pdf
An epidemiologist found five cases ofSolution Epidemiology is .pdf
 
An enterprise recently reported an EBITDA of 8million and net income.pdf
An enterprise recently reported an EBITDA of 8million and net income.pdfAn enterprise recently reported an EBITDA of 8million and net income.pdf
An enterprise recently reported an EBITDA of 8million and net income.pdf
 
An experiment consists of selecting an integer X at random from {1,..pdf
An experiment consists of selecting an integer X at random from {1,..pdfAn experiment consists of selecting an integer X at random from {1,..pdf
An experiment consists of selecting an integer X at random from {1,..pdf
 
An entomologist writes an article in a scientific journal which clai.pdf
An entomologist writes an article in a scientific journal which clai.pdfAn entomologist writes an article in a scientific journal which clai.pdf
An entomologist writes an article in a scientific journal which clai.pdf
 
An employer must hire 3 people from a list of 12 applicants. In how .pdf
An employer must hire 3 people from a list of 12 applicants. In how .pdfAn employer must hire 3 people from a list of 12 applicants. In how .pdf
An employer must hire 3 people from a list of 12 applicants. In how .pdf
 
An employer must hire 2 people from a list of 13 applicants. In how .pdf
An employer must hire 2 people from a list of 13 applicants. In how .pdfAn employer must hire 2 people from a list of 13 applicants. In how .pdf
An employer must hire 2 people from a list of 13 applicants. In how .pdf
 

Recently uploaded

Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
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
 
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
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

An Euler cycle in a directed graph is a cycle in which every edge is.pdf

  • 1. An Euler cycle in a directed graph is a cycle in which every edge is visited exactly once. Design an algorithm to test whether a given direct graph has an Euler cycle or not, and if so, find such a cycle. Solution ALGORITHM Given a starting vertex , the v0algorithm will first find a cycle C starting and ending at v0 such that C contains all edges going into and out of v0. This can be performed by a walk in the graph. As we discover vertices in cycle C, we will create a linked list which contains vertices in order and such that the list begins and ends in vertex v0. We set the current painter to the head of the list. We now traverse the list by moving our pointer "current" to successive vertices until we and a vertex which has an outgoing edge which has not been discovered. (If we reach the end of the list, then we have already found the Eule cycle ). Suppose we find the vertex, vi, that has an undiscovered outgoing edge. We then take a walk beginning and ending at vi such that all undiscovered edges containing vi are contained in the walk. We insert our new linked list into old linked list in place of vi and more "current" to the new neighbor pointed to the first node containing vi. We continue this process until we search the final node of the linked list, and the list will then contains an Euler cycle Running Time of Euler cycle The algorithm traverse each edge at most twice, first in a walk and second while traversing the list to find vertices with outgoing edges. Therefore, the total running time of the algorithm is O(|E|).