public static void CompileComparisonMatchersAsNeeded() { #if COMPILE_MATCHERS lock (compilationLock) { if (GraphMatchingState.TotalCandidateMatches() >= GraphMatchingState.TOTAL_CANDIDATE_MATCHES_NEEDED_TO_START_A_COMPILATION) { CompileComparisonMatchers(); } } #endif }
/// <summary> /// Returns whether this graph is isomorph to any of the set of graphs given, neglecting the attribute values, only structurally /// Don't call from a parallelized matcher! /// </summary> /// <param name="graphsToCheckAgainst">The other graphs we check for isomorphy against, neglecting attribute values</param> /// <returns>true if any of the graphs given is isomorph (regarding structure) to this, false otherwise</returns> public override bool HasSameStructure(IDictionary<IGraph, SetValueType> graphsToCheckAgainst) { if(graphsToCheckAgainst.Count == 0) return false; if(graphsToCheckAgainst.ContainsKey(this)) return true; lock(this) { if(this.matchingState == null) this.matchingState = new GraphMatchingState(this); if(Environment.ProcessorCount == 1 || graphsToCheckAgainst.Count == 1 || model.BranchingFactorForEqualsAny < 2) { foreach(IGraph that in graphsToCheckAgainst.Keys) { if(((LGSPGraph)that).matchingState == null) ((LGSPGraph)that).matchingState = new GraphMatchingState((LGSPGraph)that); if(matchingState.IsIsomorph(this, (LGSPGraph)that, false)) return true; } return false; } else { ++this.matchingState.numChecks; GraphMatchingState.EnsureIsAnalyzed(this); int numWorkerThreads = WorkerPool.EnsurePoolSize(Math.Min(model.BranchingFactorForEqualsAny, 64)); this.EnsureSufficientIsomorphySpacesForParallelizedMatchingAreAvailable(numWorkerThreads); matchingState.graphToCheck = this; matchingState.graphsToCheckAgainstIterator = graphsToCheckAgainst.GetEnumerator(); matchingState.iterationLock = 0; matchingState.includingAttributes_ = false; matchingState.wasIso = false; WorkerPool.Task = matchingState.IsIsomorph; WorkerPool.StartWork(Math.Min(numWorkerThreads, graphsToCheckAgainst.Count)); WorkerPool.WaitForWorkDone(); matchingState.graphToCheck = null; matchingState.graphsToCheckAgainstIterator = null; return matchingState.wasIso; } } }
/// <summary> /// Returns whether this graph is isomorph to that graph, neglecting the attribute values, only structurally /// <param name="that">The other graph we check for isomorphy against, neglecting attribute values</param> /// <returns>true if that is isomorph (regarding structure) to this, false otherwise</returns> public override bool HasSameStructure(IGraph that) { lock(this) { if(this.matchingState == null) this.matchingState = new GraphMatchingState(this); if(((LGSPGraph)that).matchingState == null) ((LGSPGraph)that).matchingState = new GraphMatchingState((LGSPGraph)that); bool result = matchingState.IsIsomorph(this, (LGSPGraph)that, false); #if CHECK_ISOCOMPARE_CANONIZATION_AGREE bool otherResult = this.Canonize() == that.Canonize(); if(result != otherResult) { List<string> thisArg = new List<string>(); thisArg.Add("this.grs"); Porter.Export((INamedGraph)this, thisArg); List<string> thatArg = new List<string>(); thatArg.Add("that.grs"); Porter.Export((INamedGraph)that, thatArg); throw new Exception("Potential internal error: Isomorphy (without attributes) and Canonization disagree"); } #endif return result; } }