예제 #1
0
        public static int CountEdgeDisjointPaths <T>(this IGraphEdges <T> graph, T startVertex, T to)
        {
            if (Eq(startVertex, to))
            {
                return(1);
            }
            var pathEdges = graph.EdgeDisjointPaths(startVertex, to);

            return(pathEdges.Where(edge => Eq(edge.Item1, startVertex)).Count());
        }
예제 #2
0
        // Returns the maximum number of edge-disjoint paths from `startVertex` to `to`, or 0 is no path.
        public static List <List <T> > FindEdgeDisjointPaths <T>(this IGraphEdges <T> graph, T startVertex, T to)
        {
            if (Eq(to, startVertex))
            {
                var paths = new List <List <T> >();
                paths.Add(new List <T>());
                paths[0].Add(startVertex);
                return(paths);
            }
            HashSet <Tuple <T, T> > pathEdges = graph.EdgeDisjointPaths(startVertex, to);

            return(ConvertEdgesToPaths(pathEdges, startVertex, to));
        }