コード例 #1
0
        public BiEdgeConnectedComponents(IGraph graph, Flags flags = Flags.None)
        {
            Graph = graph;
            BridgeDfs bridgeDfs = new BridgeDfs();

            bridgeDfs.Run(graph, null);
            Count = bridgeDfs.ComponentCount;
            if ((flags & Flags.CreateBridges) != 0)
            {
                Bridges = bridgeDfs.Bridges;
            }
            if ((flags & Flags.CreateComponents) != 0)
            {
                Subgraph subgraph = new Subgraph(graph);
                foreach (Arc bridge in bridgeDfs.Bridges)
                {
                    subgraph.Enable(bridge, false);
                }
                Components = new ConnectedComponents(subgraph, ConnectedComponents.Flags.CreateComponents).Components;
            }
        }
コード例 #2
0
        public BiEdgeConnectedComponents(IGraph graph, Flags flags = 0)
        {
            Graph = graph;
            var dfs = new BridgeDfs();

            dfs.Run(graph);

            Count = dfs.ComponentCount;
            if (0 != (flags & Flags.CreateBridges))
            {
                Bridges = dfs.Bridges;
            }
            if (0 != (flags & Flags.CreateComponents))
            {
                Subgraph withoutBridges = new Subgraph(graph);
                foreach (var arc in dfs.Bridges)
                {
                    withoutBridges.Enable(arc, false);
                }
                Components = new ConnectedComponents(withoutBridges, ConnectedComponents.Flags.CreateComponents).Components;
            }
        }