digraph/directed_graph.c
/*
 * The remove function removes a specific Vertex* pointer from the Directed Graph struct.
 */
The remove function removes a specific Vertex* pointer from the Directed Graph struct.
The remove function removes a specific Vertex * pointer from the Directed Graph struct .
bool remove_vertex(DirectedGraph* graph, void* element)
{
	if(graph == NULL || element == NULL)
		return false;
	int prevSize = linked_list_size(graph->vertexList);
	for(int i = 0; i < prevSize; i++)
	{
		Vertex* v = (Vertex*) linked_list_get(graph->vertexList, i);
		if(memcmp(v->data, element, graph->valueSize) == 0)
		{
			linked_list_remove(graph->vertexList, i);
			break;
		}
	}
	if((prevSize - linked_list_size(graph->vertexList)) == 1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
bool remove_vertex ( DirectedGraph * graph , void * element ) { if ( graph == NULL || element == NULL ) return false ; int prevSize = linked_list_size ( graph -> vertexList ) ; for ( int i = 0 ; i < prevSize ; i ++ ) { Vertex * v = ( Vertex * ) linked_list_get ( graph -> vertexList , i ) ; if ( memcmp ( v -> data , element , graph -> valueSize ) == 0 ) { linked_list_remove ( graph -> vertexList , i ) ; break ; } } if ( ( prevSize - linked_list_size ( graph -> vertexList ) ) == 1 ) { return true ; } else { return false ; } }
The remove function removes a specific Vertex* pointer from the Directed Graph struct.
The remove function removes a specific Vertex * pointer from the Directed Graph struct .
// If either parameter is NULL, return false. // Store vertex list's current size in a local variable.	 // For each vertex in the vertex list. // Retrieve the vertex in the vertex list at index i. // If this vertex is equivalent to the element parameter		 // Remove this vertex from the vertex list and break from loop. // If the previous size minus the current size equals 1 return true, else return false.