public override void Emit(SourceBuilder sourceCode) { if (ConnectednessType == CheckCandidateForConnectednessType.Source) { // emit check decision for is candidate connected to already found partial match, i.e. edge source equals node sourceCode.AppendFrontFormat("if({0}.lgspSource != {1}) ", NamesOfEntities.CandidateVariable(PatternEdgeName), NamesOfEntities.CandidateVariable(PatternNodeName)); } else if (ConnectednessType == CheckCandidateForConnectednessType.Target) { // emit check decision for is candidate connected to already found partial match, i.e. edge target equals node sourceCode.AppendFrontFormat("if({0}.lgspTarget != {1}) ", NamesOfEntities.CandidateVariable(PatternEdgeName), NamesOfEntities.CandidateVariable(PatternNodeName)); } else if (ConnectednessType == CheckCandidateForConnectednessType.SourceOrTarget) { // we've to check both node positions of the edge, we do so by checking source or target dependent on the direction run sourceCode.AppendFrontFormat("if( ({0}==0 ? {1}.lgspSource : {1}.lgspTarget) != {2}) ", NamesOfEntities.DirectionRunCounterVariable(PatternEdgeName), NamesOfEntities.CandidateVariable(PatternEdgeName), NamesOfEntities.CandidateVariable(PatternNodeName)); } else //ConnectednessType == CheckCandidateForConnectednessType.TheOther { // we've to check the node position of the edge the first node is not assigned to sourceCode.AppendFrontFormat("if( ({0}=={1}.lgspSource ? {1}.lgspTarget : {1}.lgspSource) != {2}) ", NamesOfEntities.CandidateVariable(TheOtherPatternNodeName), NamesOfEntities.CandidateVariable(PatternEdgeName), NamesOfEntities.CandidateVariable(PatternNodeName)); } // emit check failed code sourceCode.Append("{\n"); sourceCode.Indent(); CheckFailedOperations.Emit(sourceCode); sourceCode.Unindent(); sourceCode.AppendFront("}\n"); }
public override void Emit(SourceBuilder sourceCode) { if (Type == AdjustListHeadsTypes.GraphElements) { if (Parallel) { if (IsNode) { sourceCode.AppendFrontFormat("moveHeadAfterNodes[threadId].Add({0});\n", NamesOfEntities.CandidateVariable(PatternElementName)); } else { sourceCode.AppendFrontFormat("moveHeadAfterEdges[threadId].Add({0});\n", NamesOfEntities.CandidateVariable(PatternElementName)); } } else { sourceCode.AppendFrontFormat("graph.MoveHeadAfter({0});\n", NamesOfEntities.CandidateVariable(PatternElementName)); } } else //Type == AdjustListHeadsTypes.IncidentEdges { if (IncidentType == IncidentEdgeType.Incoming) { if (Parallel) { sourceCode.AppendFrontFormat("moveInHeadAfter[threadId].Add(new KeyValuePair<GRGEN_LGSP.LGSPNode, GRGEN_LGSP.LGSPEdge>({0}, {1}));\n", NamesOfEntities.CandidateVariable(StartingPointNodeName), NamesOfEntities.CandidateVariable(PatternElementName)); } else { sourceCode.AppendFrontFormat("{0}.MoveInHeadAfter({1});\n", NamesOfEntities.CandidateVariable(StartingPointNodeName), NamesOfEntities.CandidateVariable(PatternElementName)); } } else if (IncidentType == IncidentEdgeType.Outgoing) { if (Parallel) { sourceCode.AppendFrontFormat("moveOutHeadAfter[threadId].Add(new KeyValuePair<GRGEN_LGSP.LGSPNode, GRGEN_LGSP.LGSPEdge>({0}, {1}));\n", NamesOfEntities.CandidateVariable(StartingPointNodeName), NamesOfEntities.CandidateVariable(PatternElementName)); } else { sourceCode.AppendFrontFormat("{0}.MoveOutHeadAfter({1});\n", NamesOfEntities.CandidateVariable(StartingPointNodeName), NamesOfEntities.CandidateVariable(PatternElementName)); } } else // IncidentType == IncidentEdgeType.IncomingOrOutgoing { sourceCode.AppendFrontFormat("if({0}==0)", NamesOfEntities.DirectionRunCounterVariable(PatternElementName)); sourceCode.Append(" {\n"); sourceCode.Indent(); if (Parallel) { sourceCode.AppendFrontFormat("moveInHeadAfter[threadId].Add(new KeyValuePair<GRGEN_LGSP.LGSPNode, GRGEN_LGSP.LGSPEdge>({0}, {1}));\n", NamesOfEntities.CandidateVariable(StartingPointNodeName), NamesOfEntities.CandidateVariable(PatternElementName)); } else { sourceCode.AppendFrontFormat("{0}.MoveInHeadAfter({1});\n", NamesOfEntities.CandidateVariable(StartingPointNodeName), NamesOfEntities.CandidateVariable(PatternElementName)); } sourceCode.Unindent(); sourceCode.AppendFront("} else {\n"); sourceCode.Indent(); if (Parallel) { sourceCode.AppendFrontFormat("moveOutHeadAfter[threadId].Add(new KeyValuePair<GRGEN_LGSP.LGSPNode, GRGEN_LGSP.LGSPEdge>({0}, {1}));\n", NamesOfEntities.CandidateVariable(StartingPointNodeName), NamesOfEntities.CandidateVariable(PatternElementName)); } else { sourceCode.AppendFrontFormat("{0}.MoveOutHeadAfter({1});\n", NamesOfEntities.CandidateVariable(StartingPointNodeName), NamesOfEntities.CandidateVariable(PatternElementName)); } sourceCode.Unindent(); sourceCode.AppendFront("}\n"); } } }