示例#1
0
        /// <summary>Finds a vertex cut of given graph.</summary>
        /// <param name="graph">an undirected graph</param>
        /// <returns>vertices in the vertex cut</returns>
        public static IEnumerable <Vertex <TVertexId> > FindVertexCut <TVertexId, TVertexProperty, TEdgeProperty>(
            this IUndirectedGraph <TVertexId, TVertexProperty, TEdgeProperty> graph)
        {
            var strategy = new CuttingStrategy <TVertexId>();

            Searching.DfsRecursive(graph, strategy, graph.Vertices);
            return(graph.Vertices.Where(vertex => strategy.isSeparator(vertex)));
        }
示例#2
0
        /// <summary>Finds an edge cut of given graph.</summary>
        /// <param name="graph">an undirected graph</param>
        /// <returns>edges in the edge cut</returns>
        public static IEnumerable <Edge <TVertexId> > FindEdgeCut <TVertexId, TVertexProperty, TEdgeProperty>(
            this IUndirectedGraph <TVertexId, TVertexProperty, TEdgeProperty> graph)
        {
            var strategy = new CuttingStrategy <TVertexId>();

            Searching.DfsRecursive(graph, strategy, graph.Vertices);
            return(graph.Vertices
                   .Where(vertex => strategy.hasBridge(vertex))
                   .Select(vertex => graph[vertex, strategy.dfsParents[vertex]]));
        }