Example #1
0
 /// <summary>
 /// Given a procedure, find all the statements that call it.
 /// </summary>
 public IEnumerable <Statement> CallerStatements(Procedure proc)
 {
     if (!graphStms.Nodes.Contains(proc))
     {
         return(Array.Empty <Statement>());
     }
     return(graphStms.Predecessors(proc).OfType <Statement>());
 }
Example #2
0
        public void EdgeCountAfterAdd()
        {
            DirectedGraphImpl <string> gr = new DirectedGraphImpl <string>();

            gr.AddNode("a");
            gr.AddNode("b");
            Assert.AreEqual(0, gr.Successors("a").Count);
            gr.AddEdge("a", "b");
            Assert.AreEqual(1, gr.Successors("a").Count);
            Assert.AreEqual(1, gr.Predecessors("b").Count);
        }
		private string DumpGraph(DirectedGraphImpl<string> gr)
		{
			StringBuilder sb = new StringBuilder();
			foreach (string n in gr.Nodes)
			{
				sb.AppendFormat("({0} s:(", n);
				foreach (string i in gr.Successors(n))
				{
					sb.AppendFormat("{0} ", i);
				}
				sb.Append(") p:( ");
				foreach (string p in gr.Predecessors(n))
				{
					sb.AppendFormat("{0} ", p);
				}
				sb.Append(")) ");
			}
			return sb.ToString();
		}
Example #4
0
		private string DumpGraph(DirectedGraphImpl<string> gr)
		{
			StringBuilder sb = new StringBuilder();
			foreach (string n in gr.Nodes)
			{
				sb.AppendFormat("({0} s:(", n);
				foreach (string i in gr.Successors(n))
				{
					sb.AppendFormat("{0} ", i);
				}
				sb.Append(") p:( ");
				foreach (string p in gr.Predecessors(n))
				{
					sb.AppendFormat("{0} ", p);
				}
				sb.Append(")) ");
			}
			return sb.ToString();
		}
Example #5
0
 public IEnumerable <object> CallerStatements(Procedure proc)
 {
     return(graphStms.Predecessors(proc));
 }
Example #6
0
 public IEnumerable <Procedure> CallerProcedures(Procedure proc)
 {
     return(graphProcs.Predecessors(proc));
 }
 public void EdgeCountAfterRemove()
 {
     DirectedGraphImpl<string> gr = new DirectedGraphImpl<string>();
     gr.AddNode("a");
     gr.AddNode("b");
     Assert.AreEqual(0, gr.Successors("a").Count);
     gr.AddEdge("a", "b");
     gr.RemoveEdge("a", "b");
     Assert.AreEqual(0, gr.Successors("a").Count);
     Assert.AreEqual(0, gr.Predecessors("b").Count);
 }