public static DependencyGraph Graph(params object[] os)
        {
            var graph = new DependencyGraph();

            graph.AddVertexRange(os.OfType<Library>());
            graph.AddVertexRange(os.OfType<IEnumerable<Library>>()
                .SelectMany(e => e));

            graph.AddEdgeRange(os.OfType<Dependency>());
            graph.AddEdgeRange(os.OfType<IEnumerable<Dependency>>()
                .SelectMany(e => e));

            return graph;
        }
 private DependencyGraph InvertGraph(DependencyGraph graph)
 {
     var result = new DependencyGraph();
     result.AddVertexRange(graph.Vertices);
     result.AddEdgeRange(graph.Edges.Select(d =>
     {
         var tmp = d.Source;
         return d.WithSource(d.Target)
             .WithTarget(tmp);
     }));
     return result;
 }
        public static DependencyGraph Filter(DependencyGraph graph, List<OutputEntry> warnings)
        {
            var projs = new HashSet<Library>(warnings.SelectMany(w => w.Projects)
                .Concat(warnings.SelectMany(w => w.Dependencies.SelectMany(d => new[] { d.Source, d.Target }))));

            var deps = new HashSet<Dependency>(warnings.SelectMany(w => w.Dependencies));

            var filtered = new DependencyGraph();
            filtered.AddVertexRange(projs);
            //filtered.AddEdgeRange(graph.Edges.Where(d => projs.Contains(d.Source) && projs.Contains(d.Target)));
            filtered.AddEdgeRange(deps);
            return filtered;
        }
        public static DependencyGraph DependencyGraphFromXML(XElement xroot)
        {
            var libs = xroot.Descendants("Element")
                .Select(LibraryFromXML)
                .ToList();

            var libsByKey = libs.ToDictionary(ToKey, l => l);

            var deps = xroot.Descendants("Dependency")
                .Select(el => DependencyFromXML(el, libsByKey));

            var graph = new DependencyGraph();
            graph.AddVertexRange(libs);
            graph.AddEdgeRange(deps);
            return graph;
        }