Top "Topological-sort" questions

A topological sort of a directed graph produces a linear ordering of its vertices such that, for every edge uv, u comes before v in the ordering.

How to sort depended objects by dependency

I have a collection: List<VPair<Item, List<Item>> dependencyHierarchy; The first item in pair …

c# algorithm sorting dependencies topological-sort
Question from Interview, Retrieve alphabetic order from dictionary

My girlfriend got this question in an interview, and I liked it so much I thought I'd share it... Write …

algorithm puzzle graph-theory topological-sort
Topological sort using DFS without recursion

I know the common way to do a topological sort is using DFS with recursion. But how would you do …

c++ algorithm stack depth-first-search topological-sort
Algorithm for topological sorting if cycles exist

Some programming languages (like haskell) allow cyclic dependencies between modules. Since the compiler needs to know all definitions of all …

algorithm directed-graph topological-sort
deceptively simple implementation of topological sorting in python

Extracted from here we got a minimal iterative dfs routine, i call it minimal because you can hardly simplify the …

python algorithm graph-theory depth-first-search topological-sort
Topological sort to find the number of paths to t

I have to develop an O(|V|+|E|) algorithm related to topological sort which, in a directed acyclic graph (DAG), …

algorithm graph depth-first-search topological-sort
Topological sort of cyclic graph with minimum number of violated edges

I am looking for a way to perform a topological sorting on a given directed unweighted graph, that contains cycles. …

algorithm graph-theory graph-algorithm directed-graph topological-sort
Topological sort with support for cyclic dependencies

Consider the following dependencies (where A --> B means B depends on A, so effectively, A is the 'parent') …

c# sorting topological-sort
Why is topological sort needed for Longest Path in Directed Acyclic Graph?

Problem: Given a Weighted Directed Acyclic Graph (DAG) and a source vertex s in it, find the longest distances from …

graph topological-sort longest-path
Java: Access local variables from anon inner class? (PriorityQueue)

I want to use a PriorityQueue to do a topological sort on a graph. For brevity, I'd like to use …

java graph priority-queue anonymous-class topological-sort