Page 1 of 1

Adjacency Matrix in php -- vlookup in Excel

Posted: Sat Sep 24, 2011 1:15 am
by PHP_mySQL__Newbie
My actual data has 100 x-values ( x1, x2, .... x100)
and 2000 s-values (s1, s2, ...... s2000)

Question 1: Which sites were visited by at least 2 people?
Question 2: How may people visited at least 2 sites?

Problem:
5 people (x1, x2, x3, x4, x5) visited some of the 7 possible sites (s1, s2, s3, s4, s5, s6, s7)
Sample Input:
x1, s1
x2, s3
x1, s3
x3, s7
x1, s7
x5, s2
x5, s1
x5, s3

Desired Output#1: List of sites visited by at least 2 people

Code: Select all

Sites, #times, list of people
s1,         2, (x1, x5)
s3,         3, (x1, x2, x5)
Desired Output#2: List of people who visited at least 2 sites

Code: Select all

People, #times, sites
x1,         3, (s1, s3, s7)
x5,         3, (s1, s2, s3)
1) Any ideas where do I begin with?
2 Should I use an adjacency matrix?
3) Am I better off just working with Excel and use vlookup?

Re: Adjacency Matrix in php -- vlookup in Excel

Posted: Sat Sep 24, 2011 3:28 pm
by Eric!
How is your data stored? I'm guessing:

Code: Select all

x['user_name']=array("site_name"); // array of all visited sites
s['site_name']=number_of_visits; // count of site hits
If your data is stored like this then you can either loop through the data or use some of the array sorting and key sorting functions to get what you want.