src/ADT/Graph/Weighted.php
public function traverseDeepth( $source, $queue = array(), $hadNodes = false )
	{
		$nextnodeSet = array();
		if( !$hadNodes) $hadNodes = array();
		$hadNodes[] = $source->getNodeName();
		array_push($queue, $source );
		foreach( $this->getSourceNodes( $source) as $node )
		{
			if( !in_array( $node->getNodeName(), $hadNodes ) )
			{
				$hadNodes[] = $node->getNodeName();
				$nextnodeSet[] = $node;
			}
		}
		foreach( $this->getTargetNodes( $source) as $node )
		{
			if( !in_array( $node->getNodeName(), $hadNodes ) )
			{
				$hadNodes[] = $node->getNodeName();
				$queue = $this->traverseDeepth( $node, $queue, $hadNodes );
			}
		}
		foreach( $nextnodeSet as $node )
		{
			$queue = $this->traverseDeepth( $node, $queue, $hadNodes );
		}
		return $queue;
	}
public function traverseDeepth( $source, $queue = array(), $hadNodes = false )
	{
		$nextnodeSet = array();
		if( !$hadNodes) $hadNodes = array();
		$hadNodes[] = $source->getNodeName();
		array_push($queue, $source );
		foreach( $this->getSourceNodes( $source) as $node )
		{
			if( !in_array( $node->getNodeName(), $hadNodes ) )
			{
				$hadNodes[] = $node->getNodeName();
				$nextnodeSet[] = $node;
			}
		}
		foreach( $this->getTargetNodes( $source) as $node )
		{
			if( !in_array( $node->getNodeName(), $hadNodes ) )
			{
				$hadNodes[] = $node->getNodeName();
				$queue = $this->traverseDeepth( $node, $queue, $hadNodes );
			}
		}
		foreach( $nextnodeSet as $node )
		{
			$queue = $this->traverseDeepth( $node, $queue, $hadNodes );
		}
		return $queue;
	}
public function traverseDeepth ( $ source , $ queue = array ( ) , $ hadNodes = false ) { $ nextnodeSet = array ( ) ; if ( ! $ hadNodes ) $ hadNodes = array ( ) ; $ hadNodes [ ] = $ source -> getNodeName ( ) ; array_push ( $ queue , $ source ) ; foreach ( $ this -> getSourceNodes ( $ source ) as $ node ) { if ( ! in_array ( $ node -> getNodeName ( ) , $ hadNodes ) ) { $ hadNodes [ ] = $ node -> getNodeName ( ) ; $ nextnodeSet [ ] = $ node ; } } foreach ( $ this -> getTargetNodes ( $ source ) as $ node ) { if ( ! in_array ( $ node -> getNodeName ( ) , $ hadNodes ) ) { $ hadNodes [ ] = $ node -> getNodeName ( ) ; $ queue = $ this -> traverseDeepth ( $ node , $ queue , $ hadNodes ) ; } } foreach ( $ nextnodeSet as $ node ) { $ queue = $ this -> traverseDeepth ( $ node , $ queue , $ hadNodes ) ; } return $ queue ; }
Traverses graph in deepth and build queue of all Nodes.
@access		public
@param		ADT_Graph_Node	$source		Source Node
@param		ADT_List_Queue	$queue		Queue to fill with Nodes
@param		array			$hadNodes	Array of already visited Nodes
@return		ADT_List_Queue
Traverses graph in deepth and build queue of all Nodes .