Beispiel #1
0
        /// <summary>
        /// Updates the connection between two existing nodes.
        /// </summary>
        /// <param name="primaryLabel">The label of the primary node.</param>
        /// <param name="secondaryLabel">The label of the secondary node.</param>
        /// <param name="connection">The kind of connection.</param>
        public void UpdateNodeConnection(string primaryLabel, string secondaryLabel, NodeConnectionOption connection)
        {
            if (GetNodeIndex(primaryLabel) == -1)
            {
                throw new Exception("Primary label '" + primaryLabel + "' not found.");
            }
            if (GetNodeIndex(secondaryLabel) == -1)
            {
                throw new Exception("Secondary label '" + secondaryLabel + "' not found.");
            }

            for (int i = 0; i < _nodePairs.Count; i++)
            {
                NodePair pair = _nodePairs[i];

                //
                // Nodes may be mirrored (node1 is node2 and node2 is node1) depending on the order in which nodes were originally added. Check for both variations.
                //
                if (pair.Node1.Label == primaryLabel && pair.Node2.Label == secondaryLabel || pair.Node1.Label == secondaryLabel && pair.Node2.Label == primaryLabel)
                {
                    pair.Connection = connection;
                    break;
                }
            }
        }
 /// <summary>
 /// Creates a new instance of the NodePair class which represents a unique node pairing.
 /// </summary>
 /// <param name="node1">Node1 of the pair.</param>
 /// <param name="node2">Node2 of the pair.</param>
 public NodePair(Node node1, Node node2)
 {
     Node1      = node1;
     Node2      = node2;
     Connection = NodeConnectionOption.None;
 }
Beispiel #3
0
 /// <summary>
 ///  Updates the connection between the specified nodes.
 /// </summary>
 /// <param name="primaryLabel">The label of the primary node.</param>
 /// <param name="childLabel">The labels of the secondary nodes.</param>
 /// <param name="connection">The kind of connection.</param>
 public void UpdateNodeConnections(string primaryLabel, string[] secondaryLabels, NodeConnectionOption connection)
 {
     for (Int32 i = 0; i < secondaryLabels.Length; i++)
     {
         UpdateNodeConnection(primaryLabel, secondaryLabels[i], connection);
     }
 }