private void GridAdjacencyMatrix_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     foreach (var arc in digraph.Arcs)
     {
         if (arc.StartVertex != e.RowIndex || arc.EndVertex != e.ColumnIndex)
         {
             continue;
         }
         ArcName.SelectedIndex = ArcName.Items.IndexOf(arc.ToString());
         ArcLength.Text        = arc.Length.ToString(CultureInfo.CurrentCulture);
         return;
     }
     GridAdjacencyMatrix.ClearSelection();
     ArcName.Text   = (e.RowIndex + 1) + @"-" + (e.ColumnIndex + 1);
     ArcLength.Text = @"Error";
 }
 private void ArcName_TextChanged(object sender, EventArgs e)
 {
     try
     {
         int start = int.Parse(ArcName.Text[0].ToString()) - 1;
         int end   = int.Parse(ArcName.Text[2].ToString()) - 1;
         GridAdjacencyMatrix[end, start].Selected = true;
         if (GridAdjacencyMatrix[end, start].Value.ToString() == "0")
         {
             ArcLength.Text = @"Error";
             GridAdjacencyMatrix.ClearSelection();
         }
         else
         {
             ArcLength.Text = GridAdjacencyMatrix[end, start].Value.ToString();
         }
     }
     catch (Exception) { ArcLength.Text = @"Error"; }
 }