Answer the question
In order to leave comments, you need to log in
How to apply topological sort?
There is an algorithm, implementation using depth-first search: rain.ifmo.ru/cat/view.php/vis...2007/algorithm
C++ code
boolean topological_sort(){
boolean Cycle;
for(int i = 1;i <= N;i ++){
Cycle = dfs(i);
if(Cycle)return false;
}
for(int i = 1;i <= n;i ++){
Numbers[Stack.pop()] = i;
}
return true;
}
boolean dfs(int v){
if(Color[v] == 1)return true;
if(Color[v] == 2)return false;
Color[v] = 1;
for(int i = 0;i < Edges[v].size();i ++){
if(dfs(Edges[v].get(i)))return true;
}
Stack.push(v);
Color[v] = 2;
return false;
}
Answer the question
In order to leave comments, you need to log in
It is necessary to rewrite this section of code for the adjacency matrix.
for(int i = 0;i < Edges[v].size();i ++){
if(dfs(Edges[v].get(i)))return true;
}
цикл (i : все вершины)
если матрица_смежности[v, i]
если dfs(i)
return true;
UNVISITED = 0;
PARTLY_VISITED = 1;
VISITED = 2;
this is how it works
'<type:\w+>/<module:\w+>' =>'<module>',
'<type:\w+>/<module:\w+>/<site_id:\w+>' => '<module>/default/view',
add rules to rules
'<type:\w+>/<module:\w+>' =>'modules/<module>/default/index',
'<type:\w+>/<module:\w+>/<site_id:\w+>' => 'modules/<module>/default/view',
It is not clear what you have where in modules/site/default/index
if site is a module, default is a controller, and index is an action, then what are modules? There is something clearly redundant here. There must be a number of module, controller, action or controller, action or just action. What is the fourth?
If you omit this modules and I also correctly understood the rest, then:
[
'/<type>/<modul>/' => '<modul>/default/index',
'/<type>/site/<site_id>' => 'site/default/view'
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question