PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Sameer Borate's Blog: Building a adjacency matrix of a graph

Note: This article was originally published at PHPDeveloper on 21 April 1952.
PHPDeveloper

Building on the graphing tutorial in his last post Sameer continues on looking at graphs in PHP with this new post showing how to create an "agency matrix" of a currently built graph.

Building a graph is not enough; we also need the ability to search through it. To make it easier to build search algorithms, it is useful if we can represent the graph and its connections in a different way; adjacency matrix being one such representation. An adjacency matrix is a means of representing which vertices (or nodes) of a graph are adjacent to which other vertices.

He includes some sample code to extract the data from a graph (built with the PEAR Structures_Graph package) and create a basic "table" of information about each nodes' connections.