当前位置:网站首页>Lintcode:127. Topology sorting

Lintcode:127. Topology sorting

2022-06-12 20:56:00 Oceanstar's learning notes

Title source

Title Description

 Insert picture description here

#include <vector>

using namespace std;
struct DirectedGraphNode {
    
      int label;
      vector<DirectedGraphNode *> neighbors;
      DirectedGraphNode(int x) : label(x) {
    };
};


class Solution {
    
public:
    /** * @param graph: A list of Directed graph node * @return: Any topological order for the given graph. */
    vector<DirectedGraphNode*> topSort(vector<DirectedGraphNode*> graph) {
    
        // write your code here
    }
};

title

The practical meaning of topological order is : In this order , At the beginning of each project , To ensure that all its precursor activities have been completed , So that the whole project can proceed smoothly .

Be careful , Sometimes the topological order is not unique , So when interviewing, ask the following examiners , It's asking for an arbitrary solution , Or list all the solutions .

DFS

原网站

版权声明
本文为[Oceanstar's learning notes]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206122047238559.html