コード例 #1
0
        private NetworkNode_line_class[] Get_new_nodes_with_indexes_above_max_index(Add_node_line_class[] add_nodes)
        {
            int add_index = Get_max_nw_index();

            add_nodes = Add_node_line_class.Order_by_standard_way(add_nodes);
            Add_node_line_class add_node_line;
            int add_nodes_length = add_nodes.Length;
            List <NetworkNode_line_class> new_nodes = new List <NetworkNode_line_class>();
            NetworkNode_line_class        new_node_line;

            for (int indexN = 0; indexN < add_nodes_length; indexN++)
            {
                add_node_line = add_nodes[indexN];
                if ((indexN == 0) || (!add_node_line.Equal_in_standard_way(add_nodes[indexN - 1])))
                {
                    add_index++;
                    new_node_line          = new NetworkNode_line_class();
                    new_node_line.Id       = (string)add_node_line.Id.Clone();
                    new_node_line.Name     = (string)add_node_line.Name.Clone();
                    new_node_line.NW_index = add_index;
                    new_nodes.Add(new_node_line);
                }
                else
                {
                    throw new Exception();
                }
            }
            return(new_nodes.ToArray());
        }
コード例 #2
0
        public NetworkNode_line_class Deep_copy()
        {
            NetworkNode_line_class node_line = (NetworkNode_line_class)this.MemberwiseClone();

            node_line.Id    = (string)this.Id.Clone();
            node_line.Name  = (string)this.Name.Clone();
            node_line.Name2 = (string)this.Name2.Clone();
            return(node_line);
        }
コード例 #3
0
        public bool Equal_in_standard_way(NetworkNode_line_class other)
        {
            bool equal = (this.Name.Equals(other.Name));

            //bool equal = ((this.Id.Equals(other.Id))
            //              && (this.Name.Equals(other.Name))
            //              && (this.Ontology_type.Equals(other.Ontology_type))
            //              && (this.Ontology_namespace.Equals(other.Ontology_namespace)));
            return(equal);
        }
コード例 #4
0
        public NetworkNode_line_class Get_indexed_old_node_line_if_index_old_is_correct(int indexNode_old)
        {
            NetworkNode_line_class node_line = Nodes[indexNode_old];

            if (node_line.NW_index_old != indexNode_old)
            {
                node_line = new NetworkNode_line_class();
                string text = typeof(NetworkNode_class).Name + ": Get indexed old node line, Indexes_old do not match (" + indexNode_old + " <-> " + node_line.NW_index_old + ")";
                throw new Exception(text);
            }
            return(node_line);
        }
コード例 #5
0
        public NetworkNode_line_class Get_indexed_node_line_if_index_is_correct(int indexNode)
        {
            NetworkNode_line_class node_line = Nodes[indexNode];

            if (node_line.NW_index != indexNode)
            {
                node_line = new NetworkNode_line_class();
                Report_class.Write_error_line("{0}: Get indexed node line, Indexes do not match ({1} <-> {2})", typeof(NetworkNode_line_class).Name, indexNode, node_line.NW_index);
                throw new Exception();
            }
            return(node_line);
        }
コード例 #6
0
        public void Set_process_level_if_index_is_rigth(int nodeIndex, int process_level)
        {
            NetworkNode_line_class node_line = Nodes[nodeIndex];

            if (node_line.NW_index != nodeIndex)
            {
                throw new Exception("Nodes not sorted properly");
            }
            else
            {
                node_line.Level = process_level;
            }
        }
コード例 #7
0
        public void Reindex_nodes_and_set_index_old()
        {
            Nodes = NetworkNode_line_class.Order_in_standard_way(Nodes);
            NetworkNode_line_class node_line;
            int nodes_length = Nodes_length;

            for (int indexN = 0; indexN < nodes_length; indexN++)
            {
                node_line = Nodes[indexN];
                node_line.NW_index_old = node_line.NW_index;
                node_line.NW_index     = indexN;
            }
            Index_change_adopted = false;
        }
コード例 #8
0
        private void Remove_duplicates()
        {
            Nodes = NetworkNode_line_class.Order_in_standard_way(Nodes);
            int nodes_length = Nodes_length;
            NetworkNode_line_class        kept_node_line;
            List <NetworkNode_line_class> kept_nodes_list = new List <NetworkNode_line_class>();

            for (int indexN = 0; indexN < nodes_length; indexN++)
            {
                kept_node_line = this.Nodes[indexN];
                if ((indexN == 0) || (!kept_node_line.Equal_in_standard_way(this.Nodes[indexN - 1])))
                {
                    kept_nodes_list.Add(kept_node_line);
                }
                else
                {
                    throw new Exception();
                }
            }
            Nodes = kept_nodes_list.ToArray();
        }
コード例 #9
0
        private void Add_nodes(NetworkNode_line_class[] add_nodes)
        {
            int add_length  = add_nodes.Length;
            int this_length = this.Nodes_length;
            int new_length  = add_length + this_length;

            NetworkNode_line_class[] new_nodes = new NetworkNode_line_class[new_length];
            int indexNew = -1;

            for (int indexThis = 0; indexThis < this_length; indexThis++)
            {
                indexNew++;
                new_nodes[indexNew] = this.Nodes[indexThis];
            }
            for (int indexAdd = 0; indexAdd < add_length; indexAdd++)
            {
                indexNew++;
                new_nodes[indexNew] = add_nodes[indexAdd].Deep_copy();
            }
            Nodes = new_nodes;
        }
コード例 #10
0
        private NetworkNode_line_class[] Get_new_nodes_with_indexes_above_max_index(string[] add_nodeNames)
        {
            int add_index = Get_max_nw_index();

            add_nodeNames = add_nodeNames.Distinct().OrderBy(l => l).ToArray();
            string add_nodeName;
            int    add_nodeNames_length             = add_nodeNames.Length;
            List <NetworkNode_line_class> new_nodes = new List <NetworkNode_line_class>();
            NetworkNode_line_class        new_node_line;

            for (int indexN = 0; indexN < add_nodeNames_length; indexN++)
            {
                add_nodeName = add_nodeNames[indexN];
                add_index++;
                new_node_line          = new NetworkNode_line_class();
                new_node_line.Id       = "no id";
                new_node_line.Name     = (string)add_nodeName.Clone();
                new_node_line.NW_index = add_index;
                new_nodes.Add(new_node_line);
            }
            return(new_nodes.ToArray());
        }
コード例 #11
0
        public NetworkNode_line_class Get_indexed_node_line_without_checking_if_index_is_correct(int indexNode)
        {
            NetworkNode_line_class node_line = Nodes[indexNode];

            return(node_line);
        }
コード例 #12
0
 public NetworkNode_class()
 {
     Nodes = new NetworkNode_line_class[0];
     Index_change_adopted = true;
 }
コード例 #13
0
        public NetworkNode_class Merge_this_nodes_with_other_nodes_and_get_new_indexes_of_other_UN(NetworkNode_class inputOther)
        {
            NetworkNode_class other = inputOther.Deep_copy();

            this.Order_by_name();
            other.Order_by_name();
            int this_length   = this.Nodes.Length;
            int indexThis     = 0;
            int other_length  = other.Nodes.Length;
            int indexOther    = 0;
            int stringCompare = 0;
            List <NetworkNode_line_class> mergedUN   = new List <NetworkNode_line_class>();
            NetworkNode_line_class        this_line  = new NetworkNode_line_class();
            NetworkNode_line_class        other_line = new NetworkNode_line_class();
            int overlapping_nodes_count = 0;
            int indexOtherNew           = this_length - 1;

            while ((indexThis < this_length) || (indexOther < other_length))
            {
                if ((indexThis < this_length) && (indexOther < other_length))
                {
                    this_line              = this.Nodes[indexThis];
                    other_line             = other.Nodes[indexOther];
                    this_line.NW_index_old = this_line.NW_index;
                    stringCompare          = other_line.Name.CompareTo(this_line.Name);
                }
                else if (indexThis < this_length)
                {
                    this_line = this.Nodes[indexThis];
                    this_line.NW_index_old = this_line.NW_index;
                    stringCompare          = 2;
                }
                else // if (indexOther < other_count)
                {
                    other_line    = other.Nodes[indexOther];
                    stringCompare = -2;
                }
                if (stringCompare < 0) //other_line is not in this.un
                {
                    indexOtherNew++;
                    other_line.NW_index_old = other_line.NW_index;
                    other_line.NW_index     = indexOtherNew;
                    NetworkNode_line_class newOtherLine = other_line.Deep_copy();
                    newOtherLine.NW_index     = indexOtherNew;
                    newOtherLine.NW_index_old = indexOtherNew;
                    mergedUN.Add(newOtherLine);
                    indexOther++;
                }
                else if (stringCompare == 0)
                {
                    mergedUN.Add(this_line);
                    other_line.NW_index_old = other_line.NW_index;
                    other_line.NW_index     = this_line.NW_index;
                    overlapping_nodes_count++;
                    indexOther++;
                    indexThis++;
                }
                else // (stringCompare > 0)
                {
                    mergedUN.Add(this_line);
                    indexThis++;
                }
            }
            Nodes = mergedUN.ToArray();
            other.Index_change_adopted = false;

            return(other);
        }