Substructure *MakeRecursiveSub(Substructure *sub, ULONG edgeLabel, Parameters *parameters) { Substructure *recursiveSub; // parameters used Graph *posGraph = parameters->posGraph; Graph *negGraph = parameters->negGraph; recursiveSub = AllocateSub(); recursiveSub->definition = CopyGraph(sub->definition); recursiveSub->recursive = TRUE; recursiveSub->recursiveEdgeLabel = edgeLabel; recursiveSub->instances = GetRecursiveInstances(posGraph, sub->instances, sub->numInstances, edgeLabel); recursiveSub->numInstances = CountInstances(recursiveSub->instances); if (negGraph != NULL) { recursiveSub->negInstances = GetRecursiveInstances(negGraph, sub->negInstances, sub->numNegInstances, edgeLabel); recursiveSub->numNegInstances = CountInstances(recursiveSub->negInstances); } EvaluateSub(recursiveSub, parameters); return recursiveSub; }
void UpdateStatus ( void ) { extern SCREEN WinFact, WinAgenda, WinGlobal, WinInst, WinDialog; static long lastModuleIndex = -1; extern long ModuleChangeIndex; if ( lastModuleIndex != ModuleChangeIndex ) { #if DEFRULE_CONSTRUCT SetFocusChanged (CLIPS_TRUE); SetAgendaChanged (CLIPS_TRUE); #endif #if DEFTEMPLATE_CONSTRUCT SetFactListChanged (CLIPS_TRUE); #endif #if OBJECT_SYSTEM SetInstancesChanged (CLIPS_TRUE); #endif #if DEFGLOBAL_CONSTRUCT SetGlobalsChanged (CLIPS_TRUE); #endif lastModuleIndex = ModuleChangeIndex; } #if DEFRULE_CONSTRUCT /*------------------------+ | Update the Focus Window | +------------------------*/ if (IsWindowVisible(WinFocus.hWnd)) { if (GetFocusChanged()) { SetFocusChanged(CLIPS_FALSE); WinFocus.LastLine = (int) CountFocus(); UpdateWnd ( &WinFocus ); } } /*-------------------------+ | Update the Agenda Window | +-------------------------*/ if (IsWindowVisible(WinAgenda.hWnd)) { if ( GetAgendaChanged() ) { SetAgendaChanged ( CLIPS_FALSE ); WinAgenda.LastLine = (int) GetNumberOfActivations(); UpdateStatusWndTitle(WinAgenda.hWnd, "Agenda"); UpdateWnd ( &WinAgenda ); } } #endif #if DEFTEMPLATE_CONSTRUCT /*-----------------------+ | Update the Fact Window | +-----------------------*/ if (IsWindowVisible(WinFact.hWnd)) { if ( GetFactListChanged()) { SetFactListChanged ( CLIPS_FALSE ); WinFact.LastLine = CountFacts(); UpdateStatusWndTitle(WinFact.hWnd, "Facts"); UpdateWnd ( &WinFact ); } } #endif #if OBJECT_SYSTEM /*---------------------------+ | Update the Instance Window | +---------------------------*/ if (IsWindowVisible(WinInst.hWnd)) { if (GetInstancesChanged()) { SetInstancesChanged (CLIPS_FALSE); UpdateStatusWndTitle(WinInst.hWnd, "Instances"); WinInst.LastLine = CountInstances(); UpdateWnd ( &WinInst ); } } #endif #if DEFGLOBAL_CONSTRUCT /*--------------------------+ | Update the Globals Window | +--------------------------*/ if (IsWindowVisible(WinGlobal.hWnd)) { if (GetGlobalsChanged()) { SetGlobalsChanged(CLIPS_FALSE); UpdateStatusWndTitle(WinGlobal.hWnd, "Globals"); WinGlobal.LastLine = CountDefglobals(); UpdateWnd ( &WinGlobal ); } } #endif }
int main(int argc, char **argv) { Parameters *parameters; ULONG numLabels; Graph *g1; Graph *g2; Graph *g2compressed; InstanceList *instanceList; ULONG numInstances; ULONG subSize, graphSize, compressedSize; double subDL, graphDL, compressedDL; double value; Label label; parameters = GetParameters(argc, argv); g1 = ReadGraph(argv[argc - 2], parameters->labelList, parameters->directed); g2 = ReadGraph(argv[argc - 1], parameters->labelList, parameters->directed); instanceList = FindInstances(g1, g2, parameters); numInstances = CountInstances(instanceList); printf("Found %lu instances.\n\n", numInstances); g2compressed = CompressGraph(g2, instanceList, parameters); // Compute and print compression-based measures subSize = GraphSize(g1); graphSize = GraphSize(g2); compressedSize = GraphSize(g2compressed); value = ((double) graphSize) / (((double) subSize) + ((double) compressedSize)); printf("Size of graph = %lu\n", graphSize); printf("Size of substructure = %lu\n", subSize); printf("Size of compressed graph = %lu\n", compressedSize); printf("Value = %f\n\n", value); // Compute and print MDL based measures numLabels = parameters->labelList->numLabels; subDL = MDL(g1, numLabels, parameters); graphDL = MDL(g2, numLabels, parameters); numLabels++; // add one for new "SUB" vertex label if ((parameters->allowInstanceOverlap) && (InstancesOverlap(instanceList))) numLabels++; // add one for new "OVERLAP" edge label compressedDL = MDL(g2compressed, numLabels, parameters); // add extra bits to describe where external edges connect to instances compressedDL += ExternalEdgeBits(g2compressed, g1, numInstances); value = graphDL / (subDL + compressedDL); printf("DL of graph = %f\n", graphDL); printf("DL of substructure = %f\n", subDL); printf("DL of compressed graph = %f\n", compressedDL); printf("Value = %f\n\n", value); if (parameters->outputToFile) { // first, actually add "SUB" and "OVERLAP" labels label.labelType = STRING_LABEL; label.labelValue.stringLabel = SUB_LABEL_STRING; StoreLabel(& label, parameters->labelList); label.labelValue.stringLabel = OVERLAP_LABEL_STRING; StoreLabel(& label, parameters->labelList); parameters->posGraph = g2compressed; WriteGraphToDotFile(parameters->outFileName, parameters); printf("Compressed graph written to dot file %s\n", parameters->outFileName); } FreeGraph(g2compressed); FreeInstanceList(instanceList); FreeGraph(g1); FreeGraph(g2); FreeParameters(parameters); return 0; }