private void space_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     if (graph != null)
     {
         if (graph.GraphType == GraphTypes.Dense)
         {
             GraphRealization.draw <bool>(graph, color_array, connected_comps, spacing * (int)spaceX.Value, spacing * (int)spaceY.Value);
         }
         else
         {
             GraphRealization.draw <int>(graph, color_array, connected_comps, spacing * (int)spaceX.Value, spacing * (int)spaceY.Value);
         }
     }
 }
        private void onOpenGraphFileClickButton(object sender, System.Windows.RoutedEventArgs e)
        {
            algorithms = new Algorithms();
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Filter = "Text files (*.txt)|*.txt";
            if (openFileDialog.ShowDialog() == true)
            {
                globals.Filepath = openFileDialog.FileName;
                globals.Filename = Path.GetFileName(globals.Filepath);

                #region File Open
                StreamReader reader = File.OpenText(globals.Filepath);
                string       line;
                if ((line = reader.ReadLine()) != null)
                {
                    if (line.Contains(":"))
                    {
                        type = GraphTypes.Sparse;
                    }
                    else
                    {
                        type = GraphTypes.Dense;
                    }
                    reader.Close();
                }
                #endregion

                if (type == GraphTypes.Dense)
                {
                    #region Dense
                    graph = new DenseGraph();
                    AdjacencyMatrix am = new AdjacencyMatrix();

                    graph.setData(am.ParseFile <bool>(globals.Filepath));

                    int nodes_count = graph.getData <bool>().Count;
                    //number of vertices to be "colored"
                    color_array = new int[nodes_count];
                    //number of vertices which each of vertex represented by the list index and the value is the component class number
                    connected_comps = new int[nodes_count];

                    if (algorithms.isBipartite <bool>(graph, nodes_count, color_array, GraphTypes.Dense, connected_comps))
                    {
                        graph.IsBipartite = true;
                    }

                    GraphRealization.draw <bool>(graph, color_array, connected_comps, spacing, spacing);
                    #endregion
                }

                else
                {
                    #region Sparse
                    graph = new SparseGraph();
                    AdjacencyList am = new AdjacencyList();

                    graph.setData(am.ParseFile <int>(globals.Filepath));

                    int node_count = graph.getData <int>().Count;
                    //number of vertices to be colored
                    color_array = new int[node_count];
                    //number of vertices which each of vertex represented by the list index and the value is the component class number
                    connected_comps = new int[node_count];

                    if (algorithms.isBipartite <int>(graph, node_count, color_array, GraphTypes.Sparse, connected_comps))
                    {
                        graph.IsBipartite = true;
                    }

                    GraphRealization.draw <int>(graph, color_array, connected_comps, spacing, spacing);
                    #endregion
                }
                graphInfo.DataContext = graph;
            }
        }