3
I am creating an algorithm that identifies whether a graph contains cycles excluded from the sources recursively, returning the graph for later verification of the edge quantity, so create the following code for adjacency matrices:
Graph GRAPHisCycle( Graph F, vertex v) {
while( v < F->V) {
vertex w = 0;
while (w < F->V) {
if( F->adj[v][w] == 1 && GRAPHoutdeg( F, v) > 0 && GRAPHindeg( F, v) == 0) {
GRAPHremoveA( F, v, w);
GRAPHisCycle( F, v);
}
++w;
}
++v;
}
return F;
}
Graphoutdeg and Graphindeg represent the degree of output and input. I found that this code is time consuming. I don’t want to check it by topological numbering, applying a DFS, I wanted to run it using the DFS otherwise, without this check, it has like?
Your algorithm implementation doesn’t look efficient. Why perform multiple recursions ? You could store a list with the entry level 0 nos, go removing the ones from that list (and assigning the v) and after removing the edge check if w should enter the list of nos with entry grade 0.
– Felipe