hi,
im working on a project where i need to create a relation graph......
Given one user's id as input i need to fetch all his contacts and contacts of all his contacts and contacts of his contacts of contacts.....
so i need 3 levels of contacts or u could say to make it better n levels of contacts.
once i get all this information into a datastructure i need to draw a graph which has an edge between all the users who are contacts of each other. also note that the contact relationship is unidirectional meaning if A is a contact of B then its not necesarry that B is a contact of A.
right now i am working with array and i dont think thats the way to go because what happens is when i i get 1 level of contacts then there is a huge probability that one user can be a contact of more than one person thus i get a lot of redundant data....
i know i need to use classes but i cant figure out how i can make an array of objects.... below is the code that i have written so far... i have an idea but donot know how to implement..
require_once("phpFlickr.php");
$f = new phpFlickr("555013b682d0a671e42aba02d3be989d");
class contact_user
{
public:
var $nsid;
var $flag;
contact_user($id)
{
$flag=false;
$nsid=$id;
}
}//end of class contact_user
$contact = $f->contacts_getPublicList("28890953@N07");
$obj = new contact_user("28890953@N07");
foreach($contact['contact'] as $newarray)
{
$array_nsid['28890953@N07'][]=$newarray['nsid'];
$array_username['28890953@N07'][]=$newarray['username'];
$value=$newarray['nsid'];
$set[$value]['flag']="false";
$contact_level2 = $f->contacts_getPublicList($value);
foreach($contact_level2['contact'] as $newarray2)
{
$set[$value]['flag']="true";
$array_nsid[$value][]=$newarray2['nsid'];
$array_username[$value][]=$newarray2['username'];
$value2=$newarray2['nsid'];
$contact_level3 = $f->contacts_getPublicList($value2);
foreach($contact_level3['contact'] as $newarray3)
{
$array_nsid[$value2][]=$newarray3['nsid'];
$array_username[$value2][]=$newarray3['username'];
}//closing of inner most foreach
}//closing of level 2 foreach
}//closing of outermost for each
echo "<pre>";
print_r($array_nsid);
echo "</pre>";
echo "<pre>";
print_r($array_username);
echo "</pre>";
echo "</td></td></table>";
?>