Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7788241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:56:03+00:00 2026-06-01T20:56:03+00:00

I had interest in Direct Acyclic Graphs (DAG) for a long time and after

  • 0

I had interest in Direct Acyclic Graphs (DAG) for a long time and after reading about Topological sort at Wikipedia, I did not find any special mentioning of an approach involving layers numbering (although layers are extensively mentioned for drawing). With this approach the graph is not technically topologically sorted, but knowing that every node contains the correct number for layer (level), we always can tell whether a particular node “bigger” than another topologically. On the other side as long as we don’t have an ordered list, we can not enumerate the nodes topologically (although this can be done with a final conventional sort that compares the levels of the nodes).

This approach allows implementing arbitrary connecting while maintaining the correctness of levels information. The steps can be:

  • For any newly added node (without any connection) the level applied is 1.
  • If a connection between two nodes is requested (from m to n) and the n.level > m.level then they are just simply being connected, no level fixing for other nodes is required.
  • If for requested connection (from m to n) n.level<=m.level then we change n.level to (m.level + 1) and recursively check any dependencies of n for similar level increase (or no increase if the levels on a recursive step are compatible).
  • If we keep the list of recursively entered nodes then we can detect an attempt to cycle and implement some kind of undo operation (returning the levels of all affected nodes to previous values)

For any set of known nodes and connections between them, we just add all nodes applying level=1 to them and just try to apply all known connections between (ignoring and undoing cicles).

The final level information not only allows comparing nodes topologically, but contains other useful information. For example:

  • every node with level = 1 has no incoming connections (every path starts from one of them). So any DAG enumeration can be started from them.
  • The longest path (the number of edges) can not be longer than the (largest level + 1)

I suppose that for some artificial data (n nodes, every Node(n) connected to Node(n + 1)) this algorithm can be very slow. But for real-world data I tried it with (Wikipedia categories – 800,000 nodes – 2,000,000 connections) the time is decent (5-10 minutes) and the number of levels and cycle attempts is low (369 levels, 1000 cycle attempts)

So is this method new or is well-known, but just not widely presented in Wikipedia and other resources? Since it’s not a sort (technically), should it be called a data restructuring?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:56:04+00:00Added an answer on June 1, 2026 at 8:56 pm

    There are some papers on incrementally maintaining the topological order of nodes in a graph, with variations on the algorithm you describe.

    If the graph has n nodes and m edges, you spend time O(m + n) every time you insert an edge.
    The papers ask how much time will it take to insert k edges? Trivially, O(k * (n + m)). But in fact you can show much better upper bounds – something like O(k * sqrt(m + n)) for large enough k.

    Some links below, there are more:

    http://igitur-archive.library.uu.nl/math/2007-0725-201647/2005-011.pdf

    http://arxiv.org/abs/0802.1059

    http://www.siam.org/proceedings/soda/2009/SODA09_120_benderm.pdf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've had a long standing interest in developing an OS UI tailored to my
I've had a new found interest in building a small, efficient web server in
Had an interesting discussion with some colleagues about the best scheduling strategies for realtime
I have always had an interest in coding, and a while back a started
Had a few problems getting background-image displaying in Firefox, I made it work but
Had a page that was working fine. Only change I made was to add
Had a good search here but can't see anything that gets my mind in
Had a problem with the recursive conflictCheck() method. That seems fine now. I have
Had this working; at one stage. The problem is the following text is now
I had setup a password when I installed apache, mysql etc. and now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.