Class ShortestPathServer

Collaborate with ZhangZhi

Description

a python server responses every URL request which contains 'shortestpath'. It returns a Json file shows the shortest path from source to target in a weighted graph G.

Parameter

Return

Json file:

Detail Information

  1. related modules:HTTPServer, BaseHTTPRequestHander, ThreadingMixIn, urlParse

Function

  1. threadhttpserver.initdataset(): Create the social network and initial data set.
  2. threadhttpserver.getcompanydataset(): Get company information.
  3. handler.calp(source,target): Return the shortest from source to target in a weighted graph G.
  4. handler.calc(source,target): Return the shortest path from source company to target company based on a weighted people social network.
  5. handler.writejson(path): Return a json file shown on the website about shortest path from person to person.
  6. handler.writejson(cid1,cid2,pathlist): Returns a json file shown on the website. It is list of shortest path from source company to target company.

Implementation

  1. Main idea:
  2. - call initDataset() as long as the server running
  3. - after data is ready, call do_GET() function when receives an URL request.
  4. - In do_GET() function, the main idea is: extract source pid and target pid, then call Handler.calP(source,target) to get path list of pid, then call Handler.writejson(path) to generate json file. BaseHTTPRequestHandler.wfile.write(json file) to show result on browser.
  5. Add flow chat here
 
projs/clans/docs/sps.txt · Last modified: 2014/01/28 03:26 by yoyoliliu     Back to top