Topology Sorting notes

Source: Internet
Author: User

Recently, I made noip2003 to raise the first-question neural network in the group. After a long time, I had a very unclear description of the topic. I decided to give up in about five or six hours and I will get it back later.

However, by the way, I will review the topological sorting, including CLRS and data structure andAlgorithmAnalysis in C

Topological sorting is a sort of vertices in a directed acyclic graph. For example, there are a lot of things to do after you get up. You can wear underwear, sweater, coat, brush your teeth, wash your hair, and shoes for breakfast ...... But some of them need to be done first. For example, you can only wear underwear to wear a coat, but you can't wear another underwear to wear a coat. This relationship forms a directed and undirected diagram.

The algorithm is: Find a starting point number with an inbound degree of 0, and set the inbound degrees-1, loop | v | times, if no inbound value is found in the middle, there is a circle.

Because the scan times | V times, the complexity is | v | ^ 2

 

You can use queue optimization. At the beginning, a node with an inbound degree of 0 can be entered into the queue. Each time a number is generated, the inbound level associated with the node is reduced by one. Until the queue is empty. If the final part number is not equal to the number of knots, it will be circled. The complexity of using an adjacent table is | v | + | E |, which is very effective for sparse graphs.

 

CLRS uses DFS to sort the topology. I personally think it is not practical. The idea is (copy ):

1. call DFS (g) to calculate the completion time of each vertex f [v]; 2. after each vertex is complete, insert it to the front end of the linked list. 3. returns a linked list composed of vertices;

This was accidentally found on the website of the National University of Singapore, which can be accessed in blue. I have seen it before. I thought it was nju or something. The copyright is a 126 second-level domain name. It seems that many of Netease's previous domain names provide free second-level domain name services, which also reflects that NetEase is not reliable. I want to transfer 163 mailbox items to Gmail as soon as possible.

PS: I found that dual feiyan kb8 is too soft and easy to touch by mistake. Now this is the chocolate keyboard that comes with the notebook. I think it is actually quite good. In addition, the key distance is small enough. I want to change it to 8115.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.