<commit_before><?php

class AlgorithmSearchBreadthFirst{
    public function __construct(Vertex $startVertex){
        $this->vertex = $startVertex;
    }
    
    /**
     * 
     * @return array[Vertex]
     */
    public function getVertices(){
        $queue = array($this->vertex);
        $mark = array($this->vertex->getId() => true);							//to not add vertices twice in array visited
        $visited = array();														//visited vertices
        
        do{
            $t = array_shift($queue);												// get first from queue
            $visited[$t->getId()]= $t;												//save as visited
            
            $vertices = $t->getVerticesEdgeTo();									//get next vertices
            foreach($vertices as $id=>$vertex){
                if(!isset($mark[$id])){													//if not "toughed" before
                    $queue[] = $vertex;														//add to queue
                    $mark[$id] = true;														//and mark
                }
            }
        
        }while($queue);															//untill queue is empty
        
        return $visited;
    }
    
    public function getVerticesIds(){
        return array_keys($this->getVertices());
    }
}<commit_msg>add edgetGraphPathTo($destinationVertex) function which returns a Graph with the lowest vertex count between start and destination vertex<commit_after><?php

class AlgorithmSearchBreadthFirst{
    public function __construct(Vertex $startVertex){
        $this->vertex = $startVertex;
    }
    
    /**
     * 
     * @return array[Vertex]
     */
    public function getVertices(){
        $queue = array($this->vertex);
        $mark = array($this->vertex->getId() => true);							//to not add vertices twice in array visited
        $visited = array();														//visited vertices
        
        do{
            $t = array_shift($queue);												// get first from queue
            $visited[$t->getId()]= $t;												//save as visited
            
            $vertices = $t->getVerticesEdgeTo();									//get next vertices
            foreach($vertices as $id=>$vertex){
                if(!isset($mark[$id])){													//if not "toughed" before
                    $queue[] = $vertex;														//add to queue
                    $mark[$id] = true;														//and mark
                }
            }
        
        }while($queue);															//untill queue is empty
        
        return $visited;
    }
    
    /**
     * 
     * @param Vertex $destinationVertex
     * @return Graph with lowest vertex count between start and destination
     */
    public function getGraphPathTo($destinationVertex){
    	$queue = array($this->vertex);                                          //Start vertex
    	$mark = array($this->vertex->getId() => true);							//to not add vertices twice in array visited
    	
    	$deepSearchThree = $this->vertex->getGraph()->createGraphCloneEdgeless();   //create copy of graph wihtout edges
    	$visited = array();														//visited vertices
    
    	do{
    		$t = array_shift($queue);											//get first from queue
    		$visited[$t->getId()]= $t;											//save as visited
    
    		$vertices = $t->getVerticesEdgeTo();								//get next vertices
    		foreach($vertices as $id=>$vertex){
    			if(!isset($mark[$id])){											//if not "toughed" before
    				$queue[] = $vertex;											//add to queue
    				$mark[$id] = true;			                                //and mark
    															
    				$deepSearchThree->addEdge($deepSearchThree->getVertex($t->getId())->createEdgeTo($vertex));
    			}
    		}
    		
    		if(isset($mark[$destinationVertex])){                               //stop if destination node is reached
    		    $queue=null;
    		}
    
    	}while($queue);															//untill queue is empty
    	
    	//remove not used edges
    	$destinationVertexInNewGraph = $deepSearchThree->getVertex($destinationVertex->getId());
    	
    	
    	// create path
        $path = new Graph();
        $path->createVertexClone($destinationVertexInNewGraph);                 //add clone of destination vertex to path
        $currentVertex=$destinationVertexInNewGraph;
        
        
        do{                                                                     // run from the buttom to top to the tree and add the predecessor until the startvertex is reached
            $edge=$currentVertex->getIngoingEdges();                            // can only one because of the deepsearch tree
            
            $upperVertex=$edge[0]->getVertexFromTo($currentVertex);
            $path->createVertexClone($upperVertex);                             // clone upper vertex to graph
            $path->createEdgeClone($edge[0]);                                   // clone connecting edge
            $currentVertex=$upperVertex;

        }
        while($currentVertex->getId()!==$this->vertex->getId());
        
       
    
    	return $path;
    }
    
    public function getVerticesIds(){
        return array_keys($this->getVertices());
    }
}
{'fraction_non_alphanumeric': 0.1178437930356089, 'fraction_numerical': 0.0003934684241589612, 'mean_word_length': 1.4739659367396594, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2222', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1341, 'n_words': 324}