Topological_Sorting

# Topological_Sorting - Topological Ordering Preliminary to...

This preview shows pages 1–6. Sign up to view the full content.

Topological Ordering

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Preliminary to Topological Sorting LEMMA. If each node has at least one arc going out, then the first inadmissible arc of a depth first search determines a directed cycle. COROLLARY 1. If G has no directed cycle, then there is a node in G with no arcs going. And there is at least one node in G with no arcs coming in. COROLLARY 2. If G has no directed cycle, then one can relabel the nodes so that for each arc (i,j), i < j. 1 4 6 7 3
3 Initialization 1 2 4 5 3 6 7 next 0 1 2 3 4 5 6 7 8 2 2 3 2 1 1 0 2 Node Indegree Determine the indegree of each node LIST is the set of nodes with indegree of 0. “Next” will be the label of nodes in the topological order. LIST 7

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Select a node from LIST next 0 1 2 3 4 5 7 8 2 2 3 2 1 0 2 Node Indegree Select a node from LIST and delete it. LIST 7 next := next +1 order(i) := next; update indegrees update LIST 1 1 1 2 4 5 3 6 7 0 1 5 6 1
5 Select a node from LIST next 0 1 2 3 5 7 8 2 2 3 1 1 0 2 Node Indegree Select a node from LIST and delete it.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 11

Topological_Sorting - Topological Ordering Preliminary to...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online