public static IEnumerable <List <TaggedEdge <TVertex, TTag> > > GetAllPaths <TVertex, TTag>( this IBidirectionalGraph <TVertex, TaggedEdge <TVertex, TTag> > graph, IEnumerable <TVertex> sourceTypes, IEnumerable <TVertex> targetTypes, Func <TaggedEdge <TVertex, TTag>, double> weightFunc = null) { var sources = sourceTypes.ToHashSet(); var targets = targetTypes.ToHashSet(); weightFunc = weightFunc ?? (x => 1); foreach (var controller in graph.Vertices.Where(sources.Contains)) { var fromSingleSource = graph.ShortestPathsDijkstra(weightFunc, controller); foreach (var repo in graph.Vertices.Where(x => targets.Contains(x))) { IEnumerable <TaggedEdge <TVertex, TTag> > pathInGraph; if (fromSingleSource(repo, out pathInGraph)) { yield return(pathInGraph.ToList()); } } } }