Пример #1
0
		public void ShowDependencies (VertexData vertex)
		{
			Header ("{0} dependencies", vertex.value);
			if (vertex.parentIndexes == null) {
				Console.WriteLine ("Root dependency");
			} else {
				int i = 0;
				foreach (int index in vertex.parentIndexes) {
					Console.WriteLine ("Dependency #{0}", ++i);
					Console.WriteLine ("\t{0}", vertex.value);
					var childVertex = Vertex (index);
					Console.WriteLine ("\t| {0}{1}", childVertex.value, childVertex.DepsCount);
					while (childVertex.parentIndexes != null) {
						childVertex = Vertex (childVertex.parentIndexes [0]);
						Console.WriteLine ("\t| {0}{1}", childVertex.value, childVertex.DepsCount);
					}
					if (Tree)
						break;
				}
			}
		}
Пример #2
0
        void Load(GZipStream zipStream)
        {
            using (XmlReader reader = XmlReader.Create(zipStream)) {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        //Console.WriteLine (reader.Name);
                        if (reader.Name == "edge" && reader.IsStartElement())
                        {
                            string b = reader.GetAttribute("b");
                            string e = reader.GetAttribute("e");
                            //Console.WriteLine ("edge value " + b + "  -->  " + e);

                            if (e != b)
                            {
                                VertexData begin = Vertex(b, true);
                                VertexData end   = Vertex(e, true);

                                if (end.parentIndexes == null)
                                {
                                    end.parentIndexes = new List <int> ();
                                }
                                if (!end.parentIndexes.Contains(begin.index))
                                {
                                    end.parentIndexes.Add(begin.index);
                                    //Console.WriteLine (" end parent index: {0}", end.parentIndexes);
                                }
                            }
                        }
                        break;

                    default:
                        //Console.WriteLine ("node: " + reader.NodeType);
                        break;
                    }
                }
            }
        }
Пример #3
0
        public VertexData Vertex(string vertexName, bool create = false)
        {
            VertexData vertex;

            try {
                vertex = vertices [indexes [vertexName]];
            } catch (KeyNotFoundException) {
                if (create)
                {
                    int index = vertices.Count;
                    vertex = new VertexData()
                    {
                        value = vertexName, index = index
                    };
                    vertices.Add(vertex);
                    indexes.Add(vertexName, index);
                    string prefix = vertexName.Substring(0, vertexName.IndexOf(':'));
                    if (counts.ContainsKey(prefix))
                    {
                        counts [prefix]++;
                    }
                    else
                    {
                        counts [prefix] = 1;
                    }
                    //Console.WriteLine ("prefix " + prefix + " count " + counts[prefix]);
                    if (prefix == "TypeDef")
                    {
                        Types.Add(vertex);
                    }
                }
                else
                {
                    return(null);
                }
            }

            return(vertex);
        }
Пример #4
0
        IEnumerable <Tuple <VertexData, int> > AddDependencies(VertexData vertex, HashSet <int> reachedVertices, int depth)
        {
            reachedVertices.Add(vertex.index);
            yield return(new Tuple <VertexData, int> (vertex, depth));

            if (vertex.parentIndexes == null)
            {
                yield break;
            }

            foreach (var pi in vertex.parentIndexes)
            {
                var parent = Vertex(pi);
                if (reachedVertices.Contains(parent.index))
                {
                    continue;
                }

                foreach (var d in AddDependencies(parent, reachedVertices, depth + 1))
                {
                    yield return(d);
                }
            }
        }
Пример #5
0
 public List <Tuple <VertexData, int> > GetAllDependencies(VertexData vertex)
 {
     return(new List <Tuple <VertexData, int> > (AddDependencies(vertex, new HashSet <int> (), 0)));
 }
Пример #6
0
 public List <(VertexData vertex, int distance)> GetAllDependencies(VertexData vertex)
 {
     return(new List <(VertexData vertex, int distance)> (AddDependencies(vertex, new HashSet <int> (), 0)));
 }
Пример #7
0
		public VertexData Vertex (string vertexName, bool create = false)
		{
			VertexData vertex;

			try {
				vertex = vertices [indexes [vertexName]];
			} catch (KeyNotFoundException) {
				if (create) {
					int index = vertices.Count;
					vertex = new VertexData () { value = vertexName, index = index };
					vertices.Add (vertex);
					indexes.Add (vertexName, index);
					string prefix = vertexName.Substring (0, vertexName.IndexOf (':'));
					if (counts.ContainsKey (prefix))
						counts [prefix]++;
					else
						counts [prefix] = 1;
					//Console.WriteLine ("prefix " + prefix + " count " + counts[prefix]);
					if (prefix == "TypeDef") {
						Types.Add (vertex);
					}
				} else
					return null;
			}

			return vertex;
		}