Пример #1
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);
        }
Пример #2
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();
		}
Пример #3
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();
		}
Пример #4
0
 public IEnumerable <Procedure> Callees(Procedure proc)
 {
     return(graphProcs.Successors(proc));
 }
Пример #5
0
 public IEnumerable <object> Callees(Statement stm)
 {
     return(graphStms.Successors(stm));
 }
Пример #6
0
 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);
 }