Graph Transversal

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/15

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:58 PM on 9/22/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

16 Terms

1
New cards

Euler Tour

Given a (multi)graph G(V,E). An Euler tour is a cycle in G that contains each edge exactly once.

2
New cards

Euler theorem

A graph has an Euler tour if and only if it is connected and every vertex has an even degree.

3
New cards

Hierholzer’s Algorithm

Start at any unmarked edge and mark the edge to a neighbor. Continue the process at the neighbor.

If there is no such neighbor anymore, a cycle has been marked, otherwise the endpoint would have an odd degree

4
New cards

BFS

Breadth-first search first examines the neighbors of the starting vertex, then their neighbors, then their neighbors, etc., to discover paths.

ALGORITHM

GIVEN: Graph G(V,E)

Starting vertex s ∈ V

1. Create a marking array M of size n. All vertices except s are initially unmarked.

2. Initialize a queue S with s.

3. As long as S is not empty, set v to S.front() and perform S.dequeue(). Then iterate over all outgoing edges {v,w} from v. If w is unmarked, mark w and perform S.enqueue(w).

The edges from the current node to previously undiscovered nodes form a tree (BFS tree) rooted at s.

5
New cards

BFS hopdistance

knowt flashcard image
6
New cards

BFS ALGO

O(n + m)

<p>O(n + m)</p>
7
New cards

DFS

Unlike BFS, these hop distance values do not have to be minimal!
As with BFS, the edges to previously undiscovered nodes also form a tree in

DFS, which contains all nodes reachable from s.

<p>Unlike BFS, these hop distance values do not have to be minimal!<br>As with BFS, the edges to previously undiscovered nodes also form a tree in</p><p>DFS, which contains all nodes reachable from s.</p>
8
New cards

Tree edge

The edges (v,w) with pre[w] = v are also called tree edges.

9
New cards

Forward edge

Edges (v,w) that lead to nodes in the subtree of v but are not tree edges arecalled forward edges

10
New cards

Backward edge

Edges (v,w) that lead to a predecessor node of v are called backward edges.

11
New cards

Cross edge

All other edges are called cross edges. These run between different DFS

subtrees.

12
New cards

DFS lemma

In an undirected graph, there are no cross edges.

13
New cards

DFS obs

If there is a non-tree edge in an undirected graph, the graph contains a cycle.

This does not hold in directed graphs

14
New cards

Dfs as recursion

knowt flashcard image
15
New cards

DFS as stack

knowt flashcard image
16
New cards

BFS vs DFS

But only BFS guarantees minimal path length!

DFS can discover long paths faster than BFS (usually when additional

information is available). Otherwise, BFS can also be better