src/ADT/Graph/Weighted.php
public function getWays( $source, $target, $stack, $hadNodes = array() )
	{
		$ways = $newWays = array();
		if( !( $stack && is_a( $stack, "ADT_List_Stack" ) ) )
			$stack = new ADT_List_Stack();
		if( $this->isEdge( $source, $target ) )
		{
			$stack->push( $target );
			return array( $stack );
		}
		$hadNodes[] = $source->getNodeName();
		$ways = array();
		$nodes = $this->getTargetNodes( $source );
		foreach( $nodes as $node )
		{
			if( !in_array( $node->getNodeName(), $hadNodes ) )
			{
				$ways = $this->getWays( $node, $target, $stack, $hadNodes );
				if( sizeof( $ways ) )
				{
					foreach( $ways as $stack )
					{
						$stack->push( $node );
						$newWays[] = $stack;
					}
					$hasnodeSet[] = $node;
					$ways = $newWays;
				}
			}
		}
		return $ways;
	}
public function getWays( $source, $target, $stack, $hadNodes = array() )
	{
		$ways = $newWays = array();
		if( !( $stack && is_a( $stack, "ADT_List_Stack" ) ) )
			$stack = new ADT_List_Stack();
		if( $this->isEdge( $source, $target ) )
		{
			$stack->push( $target );
			return array( $stack );
		}
		$hadNodes[] = $source->getNodeName();
		$ways = array();
		$nodes = $this->getTargetNodes( $source );
		foreach( $nodes as $node )
		{
			if( !in_array( $node->getNodeName(), $hadNodes ) )
			{
				$ways = $this->getWays( $node, $target, $stack, $hadNodes );
				if( sizeof( $ways ) )
				{
					foreach( $ways as $stack )
					{
						$stack->push( $node );
						$newWays[] = $stack;
					}
					$hasnodeSet[] = $node;
					$ways = $newWays;
				}
			}
		}
		return $ways;
	}
public function getWays ( $ source , $ target , $ stack , $ hadNodes = array ( ) ) { $ ways = $ newWays = array ( ) ; if ( ! ( $ stack && is_a ( $ stack , "ADT_List_Stack" ) ) ) $ stack = new ADT_List_Stack ( ) ; if ( $ this -> isEdge ( $ source , $ target ) ) { $ stack -> push ( $ target ) ; return array ( $ stack ) ; } $ hadNodes [ ] = $ source -> getNodeName ( ) ; $ ways = array ( ) ; $ nodes = $ this -> getTargetNodes ( $ source ) ; foreach ( $ nodes as $ node ) { if ( ! in_array ( $ node -> getNodeName ( ) , $ hadNodes ) ) { $ ways = $ this -> getWays ( $ node , $ target , $ stack , $ hadNodes ) ; if ( sizeof ( $ ways ) ) { foreach ( $ ways as $ stack ) { $ stack -> push ( $ node ) ; $ newWays [ ] = $ stack ; } $ hasnodeSet [ ] = $ node ; $ ways = $ newWays ; } } } return $ ways ; }
Returns all ways between two Nodes as array of Stacks, if way exists.
@access		public
@param		ADT_Graph_Node	$source		Source Node
@param		ADT_Graph_Node	$target		Target Node
@param		ADT_ListStack	$stack		Stack to fill with Nodes on path
@param		array			$hadNodes	Array of already visited Nodes
@return		array
Returns all ways between two Nodes as array of Stacks if way exists .