Example #1
0
        public void GetCrossingEdgesCount()
        {
            var graph = GetTestGraph();

            var node0 = new MergedNode(0);
            var node1 = new MergedNode(1);
            var node2 = new MergedNode(2);
            var node3 = new MergedNode(3);

            var actual1 = MinCut.GetCrossingEdgesCount(node0.Merge(node1), node2.Merge(node3), graph);
            actual1.Should().Be(3);

            var actual2 = MinCut.GetCrossingEdgesCount(node0, node1.Merge(node2).Merge(node3), graph);
            actual2.Should().Be(2);
        }
Example #2
0
 public MergedNode Merge(MergedNode node)
 {
     if (node == null)
         throw new ArgumentNullException("node");
     return new MergedNode(Nodes.Union(node.Nodes));
 }
Example #3
0
 public static int GetCrossingEdgesCount(MergedNode node1, MergedNode node2, DirectedGraph<int> graph)
 {
     return node1.Nodes.Sum(n1 => node2.Nodes.Count(n2 => graph.GetOutNodes(n1).Contains(n2)));
 }