private QueryNode CreateQueryNode(Query query, object obj) { var queryNode = new QueryNode(query); var dict = obj as Dictionary<object, object>; if (dict == null) return queryNode; #region Unary and Binary Relation foreach (KeyValuePair<object, object> pair in dict) { var unaryNode = pair.Key as GraphNode; var binaryNode = pair.Key as Tuple<GraphNode, GraphNode>; var uunaryNode = pair.Key as List<GraphNode>; if (unaryNode != null) { #region Unary Node var eqGoal = pair.Value as EqGoal; var shapeSymbol = pair.Value as ShapeSymbol; if (eqGoal != null) { var gGoalNode = new GoalNode(eqGoal); queryNode.InternalNodes.Add(gGoalNode); CreateEdge(unaryNode, gGoalNode); continue; } if (shapeSymbol != null) { var gShapeNode = new ShapeNode(shapeSymbol); queryNode.InternalNodes.Add(gShapeNode); var sourceNode = pair.Key; Debug.Assert(sourceNode != null); CreateEdge(unaryNode, gShapeNode); continue; } #endregion } if (binaryNode != null) { #region Binary Node var gShape = pair.Value as ShapeSymbol; if (gShape != null) { var shapeNode = new ShapeNode(gShape); queryNode.InternalNodes.Add(shapeNode); var sourceNode1 = binaryNode.Item1; var sourceNode2 = binaryNode.Item2; Debug.Assert(sourceNode1 != null); Debug.Assert(sourceNode2 != null); CreateEdge(sourceNode1, shapeNode); CreateEdge(sourceNode2, shapeNode); } var gGoal = pair.Value as EqGoal; if (gGoal != null) { var goalNode = new GoalNode(gGoal); queryNode.InternalNodes.Add(goalNode); var sourceNode1 = binaryNode.Item1; var sourceNode2 = binaryNode.Item2; Debug.Assert(sourceNode1 != null); Debug.Assert(sourceNode2 != null); CreateEdge(sourceNode1, goalNode); CreateEdge(sourceNode2, goalNode); } #endregion } var findNode = SearchNode(pair.Key); if (findNode != null) { #region Find Node var eqGoal = pair.Value as EqGoal; var shapeSymbol = pair.Value as ShapeSymbol; if (eqGoal != null) { var gGoalNode = new GoalNode(eqGoal); queryNode.InternalNodes.Add(gGoalNode); CreateEdge(findNode, gGoalNode); continue; } if (shapeSymbol != null) { var gShapeNode = new ShapeNode(shapeSymbol); queryNode.InternalNodes.Add(gShapeNode); var sourceNode = pair.Key; Debug.Assert(sourceNode != null); CreateEdge(findNode, gShapeNode); continue; } #endregion } var findNodeInCurrentqQuery = queryNode.SearchInternalNode(pair.Key); if (findNodeInCurrentqQuery != null) { #region Find Node var eqGoal = pair.Value as EqGoal; var shapeSymbol = pair.Value as ShapeSymbol; if (eqGoal != null) { var gGoalNode = new GoalNode(eqGoal); queryNode.InternalNodes.Add(gGoalNode); CreateEdge(findNodeInCurrentqQuery, gGoalNode); continue; } if (shapeSymbol != null) { var gShapeNode = new ShapeNode(shapeSymbol); queryNode.InternalNodes.Add(gShapeNode); var sourceNode = pair.Key; Debug.Assert(sourceNode != null); CreateEdge(findNodeInCurrentqQuery, gShapeNode); continue; } #endregion } if (uunaryNode != null) { var equation = pair.Value as Equation; var eqNode = new EquationNode(equation); queryNode.InternalNodes.Add(eqNode); foreach (GraphNode gn in uunaryNode) { CreateEdge(gn, eqNode); } } } #endregion return queryNode; }
private QueryNode CreateQueryNode(EqGoal goal) { var query = new Query(goal.Lhs); var queryNode = new QueryNode(query); var iGoalNode = new GoalNode(goal); queryNode.InternalNodes.Add(iGoalNode); return queryNode; }
private QueryNode CreateQueryNode(List<EqGoal> goals) { var query = new Query(goals[0].Lhs); var queryNode = new QueryNode(query); foreach (EqGoal igoal in goals) { var iGoalNode = new GoalNode(igoal); queryNode.InternalNodes.Add(iGoalNode); } return queryNode; }
private static bool ConstraintCheck(QueryNode gn, object constraint1, object constraint2, out object output) { output = null; return(false); }
private static bool ConstraintCheck(QueryNode gn, object constraint, out object output) { output = null; var st = constraint as ShapeType?; if (st != null) { //TODO throw new Exception("TODO"); } var label = constraint as string; if (label != null) { #region Internal Analysis var nodes = gn.InternalNodes; //TODO foreach (var node in nodes) { var goalNode = node as GoalNode; if (goalNode != null) { bool result = ConstraintCheck(goalNode, label, out output); if (result) { goalNode.Related = true; } return(result); } var shapeNode = node as ShapeNode; if (shapeNode != null) { bool result = ConstraintCheck(shapeNode, label, out output); if (result) { shapeNode.Related = true; } return(result); } } #endregion return(false); } var eqGoal = constraint as EqGoal; if (eqGoal != null) { var nodes = gn.InternalNodes; foreach (var node in nodes) { var goalNode = node as GoalNode; if (goalNode != null) { bool result = ConstraintCheck(goalNode, eqGoal, out output); if (result) { goalNode.Related = true; return(true); } } } return(false); } var equation = constraint as Equation; if (equation != null) { #region Internal Nodes Eval var nodes = gn.InternalNodes; foreach (var node in nodes) { var goalNode = node as GoalNode; if (goalNode != null) { bool result = ConstraintCheck(goalNode, equation, out output); if (result) { goalNode.Related = true; } } } #endregion return(output != null); } return(false); }
private QueryNode CreateQueryNode(Query query, object obj) { var queryNode = new QueryNode(query); var dict = obj as Dictionary <object, object>; if (dict == null) { return(queryNode); } #region Unary and Binary Relation foreach (KeyValuePair <object, object> pair in dict) { var unaryNode = pair.Key as GraphNode; var binaryNode = pair.Key as Tuple <GraphNode, GraphNode>; var uunaryNode = pair.Key as List <GraphNode>; if (unaryNode != null) { #region Unary Node var eqGoal = pair.Value as EqGoal; var shapeSymbol = pair.Value as ShapeSymbol; if (eqGoal != null) { var gGoalNode = new GoalNode(eqGoal); queryNode.InternalNodes.Add(gGoalNode); CreateEdge(unaryNode, gGoalNode); continue; } if (shapeSymbol != null) { var gShapeNode = new ShapeNode(shapeSymbol); queryNode.InternalNodes.Add(gShapeNode); var sourceNode = pair.Key; Debug.Assert(sourceNode != null); CreateEdge(unaryNode, gShapeNode); continue; } #endregion } if (binaryNode != null) { #region Binary Node var gShape = pair.Value as ShapeSymbol; if (gShape != null) { var shapeNode = new ShapeNode(gShape); queryNode.InternalNodes.Add(shapeNode); var sourceNode1 = binaryNode.Item1; var sourceNode2 = binaryNode.Item2; Debug.Assert(sourceNode1 != null); Debug.Assert(sourceNode2 != null); CreateEdge(sourceNode1, shapeNode); CreateEdge(sourceNode2, shapeNode); } var gGoal = pair.Value as EqGoal; if (gGoal != null) { var goalNode = new GoalNode(gGoal); queryNode.InternalNodes.Add(goalNode); var sourceNode1 = binaryNode.Item1; var sourceNode2 = binaryNode.Item2; Debug.Assert(sourceNode1 != null); Debug.Assert(sourceNode2 != null); CreateEdge(sourceNode1, goalNode); CreateEdge(sourceNode2, goalNode); } #endregion } var findNode = SearchNode(pair.Key); if (findNode != null) { #region Find Node var eqGoal = pair.Value as EqGoal; var shapeSymbol = pair.Value as ShapeSymbol; if (eqGoal != null) { var gGoalNode = new GoalNode(eqGoal); queryNode.InternalNodes.Add(gGoalNode); CreateEdge(findNode, gGoalNode); continue; } if (shapeSymbol != null) { var gShapeNode = new ShapeNode(shapeSymbol); queryNode.InternalNodes.Add(gShapeNode); var sourceNode = pair.Key; Debug.Assert(sourceNode != null); CreateEdge(findNode, gShapeNode); continue; } #endregion } var findNodeInCurrentqQuery = queryNode.SearchInternalNode(pair.Key); if (findNodeInCurrentqQuery != null) { #region Find Node var eqGoal = pair.Value as EqGoal; var shapeSymbol = pair.Value as ShapeSymbol; if (eqGoal != null) { var gGoalNode = new GoalNode(eqGoal); queryNode.InternalNodes.Add(gGoalNode); CreateEdge(findNodeInCurrentqQuery, gGoalNode); continue; } if (shapeSymbol != null) { var gShapeNode = new ShapeNode(shapeSymbol); queryNode.InternalNodes.Add(gShapeNode); var sourceNode = pair.Key; Debug.Assert(sourceNode != null); CreateEdge(findNodeInCurrentqQuery, gShapeNode); continue; } #endregion } if (uunaryNode != null) { var equation = pair.Value as Equation; var eqNode = new EquationNode(equation); queryNode.InternalNodes.Add(eqNode); foreach (GraphNode gn in uunaryNode) { CreateEdge(gn, eqNode); } } } #endregion return(queryNode); }
private static bool ConstraintCheck(QueryNode gn, object constraint1, object constraint2, out object output) { output = null; return false; }
private static bool ConstraintCheck(QueryNode gn, object constraint, out object output) { output = null; var st = constraint as ShapeType?; if (st != null) { //TODO throw new Exception("TODO"); } var label = constraint as string; if (label != null) { #region Internal Analysis var nodes = gn.InternalNodes; //TODO foreach (var node in nodes) { var goalNode = node as GoalNode; if (goalNode != null) { bool result = ConstraintCheck(goalNode, label, out output); if (result) goalNode.Related = true; return result; } var shapeNode = node as ShapeNode; if (shapeNode != null) { bool result = ConstraintCheck(shapeNode, label, out output); if (result) shapeNode.Related = true; return result; } } #endregion return false; } var eqGoal = constraint as EqGoal; if (eqGoal != null) { var nodes = gn.InternalNodes; foreach (var node in nodes) { var goalNode = node as GoalNode; if (goalNode != null) { bool result = ConstraintCheck(goalNode, eqGoal, out output); if (result) { goalNode.Related = true; return true; } } } return false; } var equation = constraint as Equation; if (equation != null) { #region Internal Nodes Eval var nodes = gn.InternalNodes; foreach (var node in nodes) { var goalNode = node as GoalNode; if (goalNode != null) { bool result = ConstraintCheck(goalNode, equation, out output); if (result) { goalNode.Related = true; } } } #endregion return output != null; } return false; }