// Step 1: Find matchs. private static Rule FindMatchs(VFlibcs.Graph graphVF) { foreach (var rule in RandomOrderByWeight()) { if (rule.QuantityLimitMax == 0) { continue; } // VfState: Calculate the result of subgraph isomorphic. VFlibcs.VfState vfs = new VFlibcs.VfState(graphVF, _ruleVFgraphTable[rule], false, true); if (vfs.FMatch()) { // Reduce the quantity limit. if (rule.QuantityLimitMin > 0) { rule.QuantityLimitMin -= 1; } if (rule.QuantityLimitMax > 0) { rule.QuantityLimitMax -= 1; } _relatedNodes.Clear(); for (int i = 0; i < vfs.Mapping2To1.Length; i++) { // Set Index. Node node = graphVF.GetNodeAttr(vfs.Mapping2To1[i]) as Node; // Record this one is used in this iterating. node.Explored = true; _exploredNodeStack.Push(node); if (node.IsEdge) { continue; } node.Index = (_ruleVFgraphTable[rule].GetNodeAttr(i) as Node).Index; _relatedNodes.Add(node); } return(rule); } } return(null); }