r1ch — 2010-05-05T11:31:44-04:00 — #1
I am trying to find the shortest path that is required to fetch data about all test centres. Each test centre allows you to query upto 5 other test centres from that centre (e.g when logged in as test centre 1 you can fetch details about test centres 2,9,12,26,30) However I would then have to log into test centre 2 to fetch details about other centres e.g 10,13,16.
The dataset is concerning around 300 test centres.
My database structure is below:
CREATE TABLE IF NOT EXISTS
testcentre1 int(10) NOT NULL,
testcentre2 int(10) NOT NULL,
PRIMARY KEY (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Many thanks in advance,
r937 — 2010-05-05T12:04:01-04:00 — #2
I am trying to find the shortest path that is required to fetch data about all test centres.
what's wrong with this --
SELECT * FROM testcenters
that would return all rows, yes?
r1ch — 2010-05-05T12:06:29-04:00 — #3
Sorry r937 i did not make myself clear. I am needing to output the correct order at which to query testcentres via curl with the relationships defined in the database.
r937 — 2010-05-05T12:11:40-04:00 — #4
oh, i see
i'm gonna predict that there's no way to do this efficiently with SQL
r1ch — 2010-05-05T12:14:39-04:00 — #5
The coding environment is PHP/MySQL if this facilitates matters.
r1ch — 2010-05-05T14:40:26-04:00 — #6
Just thought id clarify things abit further. Am looking to find the value of all-pairs via the shortest path e.g find the shortest paths between every pair of nodes in the graph. Nodes in this case being the test centres of equal separation distance with the ability to start at any node. Floyd–Warshalls algorithm springs to mind however I am unable to find any examples under MySQL/PHP only PostgreSQL/PHP.
davemaxwell — 2010-05-05T15:37:43-04:00 — #7
If you can find PostgreSQL/PHP examples, that should give you a good starting point. You might need to tweak syntax, but the functionality should be the same.