Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AmirBikchentaev/d35b481fb5301f42c120a975d9129cfb to your computer and use it in GitHub Desktop.
Save AmirBikchentaev/d35b481fb5301f42c120a975d9129cfb to your computer and use it in GitHub Desktop.
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