private void UpdateDValueForNode(PartitioningNode selectedNode, IEnumerable <PartitioningNode> unmarkedNodes, IPartition thisPartition, IPartition otherPartition) { foreach (var edge in selectedNode.Node.Edges) { var otherNode = edge.GetOtherNode(selectedNode.Node); // get the partitioning node for the otherNode var pNode = unmarkedNodes.FirstOrDefault(n => n.Node.Equals(otherNode)); if (pNode == null) { continue; } // otherNode is in the same partition -> this increases (worsens) the D value of the node if (thisPartition.Nodes.Any(n => n.Equals(pNode.Node))) { // 2 * w(a', a) pNode.D += 2 * 1; } else if (otherPartition.Nodes.Any(n => n.Equals(pNode.Node))) { pNode.D -= 2 * 1; } } }
public PartitioningNodePair(PartitioningNode nodeA, PartitioningNode nodeB) { this.NodeA = nodeA; this.NodeB = nodeB; this.Gain = this.NodeA.D + this.NodeB.D - 2 * Weight(NodeA.Node, NodeB.Node); }