Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool DeleteVertex(char name)
- {
- int exists = Names.FindIndex(e => e == name);
- if (exists != -1)
- {
- int index = exists;
- int n = this.AdjacencyMatrix.GetLength(0);
- int[,] NewAdjacencyMatrix = new int[n - 1, n - 1];
- bool iFlag = false;
- for (int i = 0; i < n - 1; i++)
- {
- if (i >= index)
- iFlag = true;
- bool jFlag = false;
- for (int j = 0; j < n - 1; j++)
- {
- if (j >= index)
- jFlag = true;
- if (iFlag && jFlag)
- NewAdjacencyMatrix[i, j] = AdjacencyMatrix[i + 1, j + 1];
- else if (iFlag && !jFlag)
- NewAdjacencyMatrix[i, j] = AdjacencyMatrix[i + 1, j];
- else if (!iFlag && jFlag)
- NewAdjacencyMatrix[i, j] = AdjacencyMatrix[i, j + 1];
- else
- NewAdjacencyMatrix[i, j] = AdjacencyMatrix[i, j];
- }
- }
- AdjacencyMatrix = NewAdjacencyMatrix;
- Names.RemoveAt(index);
- return true;
- }
- else
- return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement