src/ADT/Graph/Weighted.php
public function toMatrix(  $filename = false )
	{
		if( $filename) $m = new AssocFileMatrix( $filename );
		else $m = new AssocMatrix();

		$nodes = $this->getNodes();
		foreach( $nodes as $source )
		{
			echo $source->getNodeName()."<br>";
			foreach( $nodes as $target )
			{
				if( $this->isEdge($source, $target ) || $this->isEdge($target, $source ) )
				{
					$value = $this->getEdgeValue( $source, $target );
				}
				else $value = 0;
				$m->addValueAssoc( $source->getNodeName(), $target->getNodeName(), $value );
			}
		}
		return $m;
	}
public function toMatrix(  $filename = false )
	{
		if( $filename) $m = new AssocFileMatrix( $filename );
		else $m = new AssocMatrix();

		$nodes = $this->getNodes();
		foreach( $nodes as $source )
		{
			echo $source->getNodeName()."<br>";
			foreach( $nodes as $target )
			{
				if( $this->isEdge($source, $target ) || $this->isEdge($target, $source ) )
				{
					$value = $this->getEdgeValue( $source, $target );
				}
				else $value = 0;
				$m->addValueAssoc( $source->getNodeName(), $target->getNodeName(), $value );
			}
		}
		return $m;
	}
public function toMatrix ( $ filename = false ) { if ( $ filename ) $ m = new AssocFileMatrix ( $ filename ) ; else $ m = new AssocMatrix ( ) ; $ nodes = $ this -> getNodes ( ) ; foreach ( $ nodes as $ source ) { echo $ source -> getNodeName ( ) . "<br>" ; foreach ( $ nodes as $ target ) { if ( $ this -> isEdge ( $ source , $ target ) || $ this -> isEdge ( $ target , $ source ) ) { $ value = $ this -> getEdgeValue ( $ source , $ target ) ; } else $ value = 0 ; $ m -> addValueAssoc ( $ source -> getNodeName ( ) , $ target -> getNodeName ( ) , $ value ) ; } } return $ m ; }
Returns all nodes and edges of this graph as an associative file matrix.
@access		public
@param		string	$filename		URI of File Matrix to write
@return		AssocFileMatrix
@todo		rebuild for KeyMatrix / MatrixWriter
Returns all nodes and edges of this graph as an associative file matrix .