Created
May 20, 2020 14:08
-
-
Save AmirBikchentaev/56afbddb2911227ef0e9f5f83fcad62f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void searchForArtPoints() | |
{ | |
int initialComponents = this.searhchForConnectivityComponents(-1); | |
for (int i = 0; i < graph.Count(); i++) | |
{ | |
for (int k = 0; k < graph.Count(); k++) | |
{ | |
visitedVerticesConComp[k] = false; | |
} | |
int currentComponent = this.searhchForConnectivityComponents(i); | |
if (currentComponent > initialComponents) | |
{ | |
Console.WriteLine("articulation points is"+ currentComponent); | |
} | |
} | |
} | |
public int searhchForConnectivityComponents(int verticeNotTogo) | |
{ | |
int connectivityComponentsCounter = 0; | |
for (int i = 0; i < graph.Count(); i++) | |
{ | |
if (visitedVerticesConComp[i] != true&&graph[i].Count!=0 && i!= verticeNotTogo) | |
{ | |
DFSforConnComp(i,verticeNotTogo); | |
Console.WriteLine(); | |
connectivityComponentsCounter++; | |
Console.WriteLine("the amount of "+connectivityComponentsCounter); | |
return connectivityComponentsCounter; | |
} | |
} | |
Console.WriteLine("the amount of " + connectivityComponentsCounter); | |
return connectivityComponentsCounter; | |
} | |
public void DFSforConnComp(int vertex,int verticeNotToGO) | |
{ | |
visitedVerticesConComp[vertex] = true; | |
for (int i = 0; i < graph[vertex].Count(); i++) | |
{ | |
if (!visitedVerticesConComp[graph[vertex][i]]&& graph[vertex][i]!= verticeNotToGO) | |
{ | |
Console.Write(graph[vertex][i]); | |
DFSforConnComp(graph[vertex][i],verticeNotToGO); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment