/[drupal]/contributions/modules/sna/common.php
ViewVC logotype

Diff of /contributions/modules/sna/common.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Aug 16 15:25:46 2006 UTC revision 1.2, Thu Aug 17 14:53:04 2006 UTC
# Line 64  define('PIC_WIDTH', $pic_size); Line 64  define('PIC_WIDTH', $pic_size);
64   * SVG picture height - same as width, we need 1:1 side proportion!   * SVG picture height - same as width, we need 1:1 side proportion!
65   */   */
66  define('PIC_HEIGHT', PIC_WIDTH);  define('PIC_HEIGHT', PIC_WIDTH);
67    define('ROUTE_SHORTEST', 0);
68    define('ROUTE_MIN_STEP', 1);
69  /**  /**
70   * Performace tester helper function. Start a timer and measure the current memory usage   * Performace tester helper function. Start a timer and measure the current memory usage
71   *   *
# Line 112  function lock($file_p) { Line 114  function lock($file_p) {
114   * @return nickname The uid's drupal nickname   * @return nickname The uid's drupal nickname
115   */   */
116  function get_real_name($uid) {  function get_real_name($uid) {
117    $name_q = "SELECT name FROM users WHERE uid = %d";    $name_q = "SELECT name FROM {users} WHERE uid = %d";
118    $name = db_query($name_q, $uid);    $name = db_query($name_q, $uid);
119    $line = db_fetch_array($name);    $line = db_fetch_array($name);
120    return $line["name"];    return $line["name"];
# Line 124  function get_real_name($uid) { Line 126  function get_real_name($uid) {
126   * @return array All the users uid   * @return array All the users uid
127   */   */
128  function get_all_vertices() {  function get_all_vertices() {
129    $vertices_q = "SELECT uid FROM users WHERE status = 1";    $vertices_q = "SELECT uid FROM {users} WHERE status = 1";
130    $vertices = db_query($vertices_q);    $vertices = db_query($vertices_q);
131    while ($line = db_fetch_array($vertices)) {    while ($line = db_fetch_array($vertices)) {
132      $users[] = $line['uid'];      $users[] = $line['uid'];
# Line 138  function get_all_vertices() { Line 140  function get_all_vertices() {
140   * @return array All the users uid and name   * @return array All the users uid and name
141   */   */
142  function get_all_vertices_for_forms() {  function get_all_vertices_for_forms() {
143    $vertices_q = "SELECT uid, name FROM users WHERE status = 1";    $vertices_q = "SELECT uid, name FROM {users} WHERE status = 1";
144    $vertices = db_query($vertices_q);    $vertices = db_query($vertices_q);
145    while ($line = db_fetch_array($vertices)) {    while ($line = db_fetch_array($vertices)) {
146      $users[$line['uid']] = $line['name'];      $users[$line['uid']] = $line['name'];
# Line 295  function get_edge_weight($edges, $a, $b, Line 297  function get_edge_weight($edges, $a, $b,
297   * represents connection strength   * represents connection strength
298   *   *
299   * @param array $edges The adjacentcy list of the graph   * @param array $edges The adjacentcy list of the graph
300   * @return integer The length of the edge   * @return array The strength of the minimum and the maximum edge
301   */   */
302  function get_min_and_max_degree($edges) {  function get_min_and_max_strength($edges) {
   static $cached_arr;  
303    $degrees = array();    $degrees = array();
304    if (is_array($cached_arr)) {    foreach ($edges as $neighbours) {
305      return $cached_arr;      foreach ($neighbours as $degree) {
306    }        $degrees[] = $degree;
   else {  
     foreach ($edges as $neighbours) {  
       foreach ($neighbours as $degree) {  
         $degrees[] = $degree;  
       }  
307      }      }
     sort($degrees);  
     $cached_arr = array(reset($degrees), end($degrees));  
     return $cached_arr;  
308    }    }
309      sort($degrees);
310      return array(reset($degrees), end($degrees));
311  }  }
312    
313  /**  /**

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2