public void TestScenario_28_WorkedExample_0() { var graph = new RelationGraph(); var y = new Var("y"); var pt1 = new Point("A", 2, y); var pt1Symbol = new PointSymbol(pt1); var pt2 = new Point("B", -1, 4); var pt2Symbol = new PointSymbol(pt2); graph.AddNode(pt1Symbol); graph.AddNode(pt2Symbol); var eqGoal = new EqGoal(y, -1); graph.AddNode(eqGoal); Assert.True(pt1Symbol.CachedSymbols.Count == 1); var ptNode = graph.RetrieveShapeNode(pt1Symbol); Assert.True(ptNode.InEdges.Count == 1); var query2 = new Query("d"); var queryNode2 = graph.AddNode(query2) as QueryNode; Assert.NotNull(queryNode2); Assert.True(query2.Success); Assert.True(query2.CachedEntities.Count == 1); var cachedGoal = query2.CachedEntities.ToList()[0] as EqGoal; Assert.NotNull(cachedGoal); Assert.True(cachedGoal.ToString().Equals("d=5.83")); }
public void TestScenario_06_WorkedExample_2() { var graph = new RelationGraph(); var pt1 = new Point(2, 3); var pt1Symbol = new PointSymbol(pt1); var y = new Var("y"); var pt2 = new Point(4, y); var pt2Symbol = new PointSymbol(pt2); graph.AddNode(pt1Symbol); graph.AddNode(pt2Symbol); var m = new Var("m"); var eqGoal = new EqGoal(m, 5); graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 4); Assert.True(graph.FoundCycleInGraph()); var ptNode = graph.RetrieveShapeNode(pt2Symbol); Assert.True(ptNode.InEdges.Count == 1); Assert.True(pt2Symbol.CachedSymbols.Count == 1); var query3 = new Query("k"); var queryNode3 = graph.AddNode(query3) as QueryNode; Assert.NotNull(queryNode3); Assert.True(query3.Success); Assert.True(query3.CachedEntities.Count == 1); var cachedGoal = query3.CachedEntities.ToList()[0] as EqGoal; Assert.NotNull(cachedGoal); Assert.True(cachedGoal.ToString().Equals("k=-7")); }
public void TestScenario_02_WorkedExample_1() { //add three nodes in sequence //delete d=5 var graph = new RelationGraph(); var pt1 = new Point("A", 2, 4); var pt1Symbol = new PointSymbol(pt1); var v = new Var("v"); var pt2 = new Point("B", 5, v); var pt2Symbol = new PointSymbol(pt2); graph.AddNode(pt1Symbol); graph.AddNode(pt2Symbol); var d = new Var("d"); var eqGoal = new EqGoal(d, 5); graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 5); //Form a Cycle Directed Graph Assert.True(graph.FoundCycleInGraph()); var ptNode = graph.RetrieveShapeNode(pt2Symbol); Assert.True(ptNode.InEdges.Count == 2); graph.DeleteNode(eqGoal); Assert.True(graph.Nodes.Count == 2); var pt1Node = graph.RetrieveShapeNode(pt1Symbol); Assert.NotNull(pt1Node); Assert.True(pt1Node.InEdges.Count == 0); Assert.True(pt1Node.OutEdges.Count == 0); var pt2Node = graph.RetrieveShapeNode(pt2Symbol); Assert.NotNull(pt2Node); Assert.True(pt2Node.InEdges.Count == 0); Assert.True(pt2Node.OutEdges.Count == 0); }
public void TestScenario_06_WorkedExample_3() { var graph = new RelationGraph(); var pt1 = new Point(2, 3); var pt1Symbol = new PointSymbol(pt1); graph.AddNode(pt1Symbol); var query2 = new Query("lineG"); var queryNode2 = graph.AddNode(query2) as QueryNode; Assert.Null(queryNode2); Assert.False(query2.Success); var y = new Var("y"); var pt2 = new Point(4, y); var pt2Symbol = new PointSymbol(pt2); graph.AddNode(pt2Symbol); var m = new Var("m"); var eqGoal = new EqGoal(m, 5); graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 5); Assert.True(graph.FoundCycleInGraph()); var ptNode = graph.RetrieveShapeNode(pt2Symbol); Assert.True(ptNode.InEdges.Count == 1); Assert.True(pt2Symbol.CachedSymbols.Count == 1); Assert.True(query2.Success); Assert.True(query2.CachedEntities.Count == 1); var cachedLine = query2.CachedEntities.ToList()[0] as LineSymbol; Assert.NotNull(cachedLine); Assert.True(cachedLine.ToString().Equals("5x-y-7=0")); }
public void TestScenario_02_WorkedExample_2() { //add three nodes in sequence //delete point A var graph = new RelationGraph(); var pt1 = new Point("A", 2, 4); var pt1Symbol = new PointSymbol(pt1); var v = new Var("v"); var pt2 = new Point("B", 5, v); var pt2Symbol = new PointSymbol(pt2); graph.AddNode(pt1Symbol); graph.AddNode(pt2Symbol); var d = new Var("d"); var eqGoal = new EqGoal(d, 5); graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 5); //Form a Cycle Directed Graph Assert.True(graph.FoundCycleInGraph()); var ptNode = graph.RetrieveShapeNode(pt2Symbol); Assert.True(ptNode.InEdges.Count == 2); graph.DeleteNode(pt1Symbol); Assert.True(graph.Nodes.Count == 2); var pt2Node = graph.RetrieveShapeNode(pt2Symbol); Assert.NotNull(pt2Node); Assert.True(pt2Node.InEdges.Count == 0); Assert.True(pt2Node.OutEdges.Count == 0); }
public void TestScenario_02_WorkedExample_0() { //add three nodes in sequence var graph = new RelationGraph(); var pt1 = new Point("A", 2, 4); var pt1Symbol = new PointSymbol(pt1); var v = new Var("v"); var pt2 = new Point("B", 5, v); var pt2Symbol = new PointSymbol(pt2); graph.AddNode(pt1Symbol); graph.AddNode(pt2Symbol); var d = new Var("d"); var eqGoal = new EqGoal(d, 5); graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 5); //Form a Cycle Directed Graph Assert.True(graph.FoundCycleInGraph()); var ptNode = graph.RetrieveShapeNode(pt2Symbol); Assert.True(ptNode.InEdges.Count == 2); Assert.True(pt2Symbol.CachedSymbols.Count == 2); var query = new Query("v"); var queryNode = graph.AddNode(query) as QueryNode; Assert.NotNull(queryNode); Assert.True(query.Success); Assert.True(query.CachedEntities.Count == 2); var gGoal1 = query.CachedEntities.ToList()[0] as EqGoal; Assert.NotNull(gGoal1); var query2 = new Query("AB"); var queryNode2 = graph.AddNode(query2) as QueryNode; Assert.Null(queryNode2); Assert.False(query2.Success); query2.Constraint2 = ShapeType.LineSegment; queryNode2 = graph.AddNode(query2) as QueryNode; Assert.NotNull(queryNode2); Assert.True(query2.Success); Assert.True(query2.CachedEntities.ToList().Count == 2); /* query2.Constraint2 = ShapeType.Line; queryNode2 = graph.AddNode(query2) as QueryNode; Assert.NotNull(queryNode2); Assert.True(query2.Success); Assert.True(query2.CachedEntities.ToList().Count == 2);*/ //Instructional Scaffolding Verify (Trace Generation) //1. check v=0's trace Assert.True(gGoal1.Traces.Count == 3); //2. check point trace Assert.True(pt2Symbol.CachedSymbols.Count == 2); var cachedPt1 = pt2Symbol.CachedSymbols.ToList()[0]; Assert.NotNull(cachedPt1); Assert.True(cachedPt1.Traces.Count == 4); var cachedPt2 = pt2Symbol.CachedSymbols.ToList()[1]; Assert.NotNull(cachedPt2); Assert.True(cachedPt2.Traces.Count == 4); //3. check AB's plotting trace var cachedLineSeg1 = query2.CachedEntities.ToList()[0] as LineSegmentSymbol; Assert.NotNull(cachedLineSeg1); //Assert.True(cachedLineSeg1.Traces.Count == 3); }
public void TestScenario_02_WorkedExample_0() { //add three nodes in sequence var graph = new RelationGraph(); var pt1 = new Point("A", 2, 4); var pt1Symbol = new PointSymbol(pt1); var v = new Var("v"); var pt2 = new Point("B", 5, v); var pt2Symbol = new PointSymbol(pt2); graph.AddNode(pt1Symbol); graph.AddNode(pt2Symbol); var d = new Var("d"); var eqGoal = new EqGoal(d, 5); graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 5); //Form a Cycle Directed Graph Assert.True(graph.FoundCycleInGraph()); var ptNode = graph.RetrieveShapeNode(pt2Symbol); Assert.True(ptNode.InEdges.Count == 2); Assert.True(pt2Symbol.CachedSymbols.Count == 2); var query = new Query("v"); var queryNode = graph.AddNode(query) as QueryNode; Assert.NotNull(queryNode); Assert.True(query.Success); Assert.True(query.CachedEntities.Count == 2); var gGoal1 = query.CachedEntities.ToList()[0] as EqGoal; Assert.NotNull(gGoal1); var query2 = new Query("AB"); var queryNode2 = graph.AddNode(query2) as QueryNode; Assert.Null(queryNode2); Assert.False(query2.Success); query2.Constraint2 = ShapeType.LineSegment; queryNode2 = graph.AddNode(query2) as QueryNode; Assert.NotNull(queryNode2); Assert.True(query2.Success); Assert.True(query2.CachedEntities.ToList().Count == 2); /* query2.Constraint2 = ShapeType.Line; * queryNode2 = graph.AddNode(query2) as QueryNode; * Assert.NotNull(queryNode2); * Assert.True(query2.Success); * Assert.True(query2.CachedEntities.ToList().Count == 2);*/ //Instructional Scaffolding Verify (Trace Generation) //1. check v=0's trace Assert.True(gGoal1.Traces.Count == 3); //2. check point trace Assert.True(pt2Symbol.CachedSymbols.Count == 2); var cachedPt1 = pt2Symbol.CachedSymbols.ToList()[0]; Assert.NotNull(cachedPt1); Assert.True(cachedPt1.Traces.Count == 4); var cachedPt2 = pt2Symbol.CachedSymbols.ToList()[1]; Assert.NotNull(cachedPt2); Assert.True(cachedPt2.Traces.Count == 4); //3. check AB's plotting trace var cachedLineSeg1 = query2.CachedEntities.ToList()[0] as LineSegmentSymbol; Assert.NotNull(cachedLineSeg1); //Assert.True(cachedLineSeg1.Traces.Count == 3); }