Opened 14 years ago
Last modified 6 years ago
#421 new enhancement
Better DAG test and topological ordering implementation
| Reported by: | Alpar Juttner | Owned by: | Alpar Juttner |
|---|---|---|---|
| Priority: | major | Milestone: | LEMON 1.4 release |
| Component: | core | Version: | hg main |
| Keywords: | Cc: | ||
| Revision id: |
Description (last modified by )
Currently all these functions use Dfs with a custom visitor. I have a feeling that a direct algorithm might be faster and/or more memory efficient. The algorithm I propose is the following:
- Compute the in-degree of all nodes and store them in a
NodeMapdeg. - Put all node
nwithdeg[n]==0into a queue (or a stack)q. - While
qis not empty:- Get a node
nfromq. This is the next node in the topological order. - For each out-arc
aofn:- Decrease
deg[target(a)]by 1 - If
deg[target(a)]==0then puttarget(a)intoq
- Decrease
- Get a node
Attachments (1)
Change History (3)
comment:1 Changed 13 years ago by
| Milestone: | LEMON 1.3 release → LEMON 1.4 release |
|---|
Changed 11 years ago by
comment:2 Changed 6 years ago by
| Description: | modified (diff) |
|---|
Note: See
TracTickets for help on using
tickets.


Implementation of the proposed TopologicalSort?