digraph/directed_graph.c
/*
 * The source_vertex function takes a DirectedGraph* struct pointer parameter and
 * traverses the Directed Graph structure from each vertex. The vertex from which
 * all vertices can be visited is returned. If no such vertex exists, then NULL
 * is returned.
 */
The source_vertex function takes a DirectedGraph* struct pointer parameter and
traverses the Directed Graph structure from each vertex. The vertex from which
all vertices can be visited is returned. If no such vertex exists, then NULL
is returned.
The source_vertex function takes a DirectedGraph * struct pointer parameter and traverses the Directed Graph structure from each vertex . The vertex from which all vertices can be visited is returned . If no such vertex exists then NULL is returned .
void* source_vertex(DirectedGraph* graph)
{
	if(graph == NULL)
		return NULL;
	LinkedList* list = get_vertices(graph);
	for(int i = 0; i < linked_list_size(list); i++)
	{
		void* v   = linked_list_get(list, i);
		int count = connected_vertices_count(graph, v);
		if(count == linked_list_size(list))
		{
			set_visited_field(graph, false);
			return v;
		}
		set_visited_field(graph, false);
	}
	return NULL;
}
void * source_vertex ( DirectedGraph * graph ) { if ( graph == NULL ) return NULL ; LinkedList * list = get_vertices ( graph ) ; for ( int i = 0 ; i < linked_list_size ( list ) ; i ++ ) { void * v = linked_list_get ( list , i ) ; int count = connected_vertices_count ( graph , v ) ; if ( count == linked_list_size ( list ) ) { set_visited_field ( graph , false ) ; return v ; } set_visited_field ( graph , false ) ; } return NULL ; }
The source_vertex function takes a DirectedGraph* struct pointer parameter and
 traverses the Directed Graph structure from each vertex.
The source_vertex function takes a DirectedGraph * struct pointer parameter and traverses the Directed Graph structure from each vertex .
// Retrieve the vertex list from the Dorected Graph struct. // For each vertex in the vertex list. // Retrieve the vertex at index i. // Retrieve the count of the call to connected_verteices_count function from this vertex. // If number of vertices visited equals number of vertices in the graph. // Set the visieted falg for all vertices to false and return this vertex. // Set the visited flag for all vertices in the graph to false. 