예제 #1
0
파일: read_graph.c 프로젝트: shliu/UKY
void explore(node_t * mygraph, int node)
{
	mygraph[node].visited = 1;
	previsit(mygraph, node);
	edge_t *pointer = mygraph[node].edge_list;
	while(pointer != NULL)
	{
		if(mygraph[pointer->n_index].visited != 1)
		{
			explore(mygraph, pointer->n_index);
		}
		pointer = pointer->next;
	}
	postvisit(mygraph, node);
}
예제 #2
0
void dfs(int vertices[][4],int edges[][4],int v)
{
int counter,i;
			//printf("The dfs function is called for exploring the vertex %d\n",v);
			if(vertices[v-1][1]!=1)
			{
			previsit(vertices,v);
			vertices[v-1][1]=1;
				for(counter=0;counter<5;counter++)
				{
				//printf("After setting the pre value for vertex:%d	: %d %d %d %d\n",v,vertices[counter][0],vertices[counter][1],vertices[counter][2],vertices[counter][3]);
				}
		
				for(i=0;i<no_of_edges;i++)
				{
					if(edges[i][0]==v)
					{
					//printf("\nRecursion Vertex %d has an edge to vertex:%d	",edges[i][0],edges[i][1]);
					dfs(vertices,edges,edges[i][1]);
					}				
				}
			postvisit(vertices,v);
			} 
}