-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
executable file
·58 lines (49 loc) · 1.46 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "graph.h"
int main(int argc, char const *argv[])
{
graphS* graph = initializeGraph(readNumNodes());
readGraph(graph);
queueS *nodesQueue = createQueue();
int testNode,v;
int insufficientError;
int nodesDiscovered = 0;
listNodeS *nodeEdge;
for(v = 1; v <= graph->numNodes; v++){
insufficientError = -1;
if (testEntryArch(graph->entrysNodes, v)){
insufficientError++;
enqueue(nodesQueue,v);
}
}
while (nodesQueue->head!=NULL){
testNode = dequeue(nodesQueue);
enqueue(graph->path, testNode);
nodesDiscovered++;
insufficientError = -1;
for(nodeEdge = graph->nodesEdges[testNode]->next; nodeEdge != NULL; nodeEdge=nodeEdge->next){
deleteEntryArch(graph->entrysNodes, nodeEdge->node);
if (testEntryArch(graph->entrysNodes, nodeEdge->node)){
insufficientError++;
enqueue(nodesQueue, nodeEdge->node);
}
}
}
/*caso seja detetado o erro insuficente o ciclo continua para decobrir se tambem e incoerente*/
while (nodesQueue->head!=NULL){
nodesDiscovered++;
testNode = dequeue(nodesQueue);
for(nodeEdge = graph->nodesEdges[testNode]->next; nodeEdge != NULL; nodeEdge=nodeEdge->next){
deleteEntryArch(graph->entrysNodes, nodeEdge->node);
if (testEntryArch(graph->entrysNodes, nodeEdge->node))
enqueue(nodesQueue, nodeEdge->node);
}
}
if (nodesDiscovered < graph->numNodes)
printError("Incoerente");
else if(insufficientError == 1)
printError("Insuficiente");
/*else
printPath(graph->path);
*/
return 0;
}