static void graph_InternSCC(GRAPH Graph, GRAPHNODE Node) /************************************************************** INPUT: A graph and a node of the graph. RETURNS: Nothing. EFFECT: This is an internal function used by graph_StronglyConnnectedComponents. It sets information in the graph structure which specifies the strongly connected components of the graph. ***************************************************************/ { GRAPHNODE n; LIST scan; NAT act_dfs; act_dfs = (Graph->dfscount)++; graph_NodeSetDfsNum(Node, act_dfs); graph_UNFINISHED = list_Push(Node, graph_UNFINISHED); graph_ROOTS = list_Push(Node, graph_ROOTS); /* putchar('\n'); list_Apply(graph_NodePrint, graph_UNFINISHED); putchar('\n'); list_Apply(graph_NodePrint, graph_ROOTS); fflush(stdout); DBG */ for (scan = graph_NodeNeighbors(Node); !list_Empty(scan); scan = list_Cdr(scan)) { n = list_Car(scan); if (!graph_NodeVisited(n)) { graph_InternSCC(Graph, n); /* Visit <n> */ } else if (!graph_NodeCompleted(n)) { /* <n> was visited but is not yet in a permanent component */ NAT dfs_num_of_n = graph_NodeDfsNum(n); while (!list_StackEmpty(graph_ROOTS) && graph_NodeDfsNum(list_Top(graph_ROOTS)) > dfs_num_of_n) graph_ROOTS = list_Pop(graph_ROOTS); /* putchar('\n'); list_Apply(symbol_Print, graph_UNFINISHED); putchar('\n'); list_Apply(symbol_Print, graph_ROOTS); fflush(stdout); DBG */ } } /* printf("\nDFS(%u) complete.", graph_NodeNumber(Node)); DBG */ if (Node == list_Top(graph_ROOTS)) { /* Node is root of a component, so make this component permanent */ while (!list_StackEmpty(graph_UNFINISHED) && graph_NodeDfsNum(list_Top(graph_UNFINISHED)) >= act_dfs) { n = list_Top(graph_UNFINISHED); graph_UNFINISHED = list_Pop(graph_UNFINISHED); graph_NodeSetCompNum(n, Graph->compcount); } Graph->compcount++; graph_ROOTS = list_Pop(graph_ROOTS); } /* putchar('\n'); list_Apply(graph_NodePrint, graph_UNFINISHED); putchar('\n'); list_Apply(graph_NodePrint, graph_ROOTS); fflush(stdout); DBG */ }
static LIST split_RemoveUnnecessarySplits(PROOFSEARCH PS, CLAUSE EmptyClause) /************************************************************** INPUT: An empty clause and a proof search object EFFECT: Removes all splits up to the last backtrack level that were not necessary to derive the empty clause. RETURNS: A list of recovered clauses. ***************************************************************/ { LIST Scan; LIST Recover, New; LIST Deleted; LIST ScanStack; int SplitLevel; int LastBacktrackLevel; SPLIT Split,ScanSplit; Scan = prfs_SplitStack(PS); SplitLevel = prfs_ValidLevel(PS); LastBacktrackLevel = prfs_LastBacktrackLevel(PS); Recover = list_Nil(); while (SplitLevel > LastBacktrackLevel) { if (prfs_SplitIsUnused(list_Car(Scan)) && !clause_DependsOnSplitLevel(EmptyClause, SplitLevel)) { New = list_Nil(); Split = list_Car(Scan); /*printf("\n\t Removed: %d",prfs_SplitSplitLevel(Split));*/ clause_DeleteClauseList(prfs_SplitBlockedClauses(Split)); prfs_SplitSetBlockedClauses(Split, list_Nil()); Recover = list_Nconc(prfs_SplitDeletedClauses(Split), Recover); prfs_SplitSetDeletedClauses(Split, list_Nil()); if (prfs_SplitFatherClause(Split) != (CLAUSE)NULL) { Recover = list_Cons(prfs_SplitFatherClause(Split),Recover); prfs_SplitSetFatherClause(Split,NULL); } Recover = split_DeleteClausesDependingOnLevelFromList(PS, Recover, SplitLevel, &New); ScanStack = prfs_SplitStack(PS); while (!list_StackEmpty(ScanStack) && prfs_SplitSplitLevel((ScanSplit = (SPLIT)list_Car(ScanStack))) > LastBacktrackLevel) { Deleted = prfs_SplitDeletedClauses(ScanSplit); prfs_SplitSetDeletedClauses(ScanSplit, list_Nil()); /* IMPORTANT!, see next line */ Deleted = split_DeleteClausesDependingOnLevelFromList(PS, Deleted, SplitLevel, &New); prfs_SplitSetDeletedClauses(ScanSplit, Deleted); ScanStack = list_Cdr(ScanStack); } while (!list_Empty(New)) { Deleted = list_Nil(); Recover = list_Nconc(split_DeleteClausesDependingOnLevelFromList(PS, New, SplitLevel, &Deleted), Recover); New = Deleted; } Recover = list_Nconc(Recover, split_DeleteClausesDependingOnLevelFromSet(PS, prfs_UsableClauses(PS), SplitLevel)); Recover = list_Nconc(Recover, split_DeleteClausesDependingOnLevelFromSet(PS, prfs_WorkedOffClauses(PS), SplitLevel)); prfs_SplitSetUsed(Split); } SplitLevel--; Scan = list_Cdr(Scan); } return Recover; }