Beispiel #1
0
        private void Generate_and_add_yed_node_color_lines_for_all_neighbors_that_are_siblings(int indexNW)
        {
            Network_line_class     nw_line        = Process_nw.NW[indexNW];
            NetworkNode_line_class this_node_line = Process_nw.Nodes.Get_indexed_node_line_if_index_is_correct(indexNW);

            if (!NodeIndex_colorIndex_dict.ContainsKey(indexNW))
            {
                Already_considered_neighbors.Clear();
                int[] all_neighborIndexes_siblings = Identify_all_neighborIndexes_that_are_siblings_recursive(indexNW);
                int   indexColor = Identify_free_colorIndex_that_is_not_used_by_neighbors(all_neighborIndexes_siblings);
                Generate_new_yed_node_color_line_and_add_to_dictionary_and_list(indexNW, indexColor);
                int all_neighborIndexes_siblings_length = all_neighborIndexes_siblings.Length;
                int neighborIndex_sibling;
                for (int indexS = 0; indexS < all_neighborIndexes_siblings_length; indexS++)
                {
                    neighborIndex_sibling = all_neighborIndexes_siblings[indexS];
                    if (!NodeIndex_colorIndex_dict.ContainsKey(neighborIndex_sibling))
                    {
                        Generate_new_yed_node_color_line_and_add_to_dictionary_and_list(neighborIndex_sibling, indexColor);
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
            }
        }
Beispiel #2
0
        private void Generate_new_yed_node_color_line_and_add_to_dictionary_and_list(int indexNW, int indexColor)
        {
            Color_enum current_rotation_color = Rotation_colors[indexColor];

            NetworkNode_line_class    node_line           = Process_nw.Nodes.Get_indexed_node_line_if_index_is_correct(indexNW);
            yed_node_color_line_class new_node_color_line = new yed_node_color_line_class();

            new_node_color_line.Hexadecimal_color = Hexadecimal_color_class.Get_hexadecimial_code_for_color(current_rotation_color);
            new_node_color_line.NodeName          = (string)node_line.Name.Clone();
            NodeIndex_colorIndex_dict.Add(indexNW, indexColor);
            Color_lines_list.Add(new_node_color_line);
        }
Beispiel #3
0
        private int Identify_free_colorIndex_that_is_not_used_by_neighbors(int[] sibling_indexes)
        {
            int        sibling_indexes_length = sibling_indexes.Length;
            int        sibling_index;
            List <int> used_colors = new List <int>();

            Network_target_line_class[] target_lines;
            int target_lines_length;
            int target_line_nwIndex;

            for (int indexS = 0; indexS < sibling_indexes_length; indexS++)
            {
                sibling_index       = sibling_indexes[indexS];
                target_lines        = Process_nw.NW[sibling_index].Targets;
                target_lines_length = target_lines.Length;
                for (int indexT = 0; indexT < target_lines_length; indexT++)
                {
                    target_line_nwIndex = target_lines[indexT].NW_index;
                    if (NodeIndex_colorIndex_dict.ContainsKey(target_line_nwIndex))
                    {
                        used_colors.Add(NodeIndex_colorIndex_dict[target_line_nwIndex]);
                    }
                }
            }
            used_colors = used_colors.Distinct().OrderBy(l => l).ToList();
            int colorIndex = Start_indexColor;

            do
            {
                if (!used_colors.Contains(colorIndex))
                {
                    break;
                }
                else
                {
                    colorIndex++;
                }
                if (colorIndex == Rotation_colors_length)
                {
                    colorIndex = 0;
                }
            } while (colorIndex != Start_indexColor);
            Start_indexColor++;
            if (Start_indexColor == Rotation_colors_length)
            {
                Start_indexColor = 0;
            }
            return(colorIndex);
        }