modules/query/LineGraphTable.js
function buildGraph(db, callback) {

  // Check cache for graph
  let cacheKey = db.id + "-graph";
  let cache = cache_graph.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }

  // Build Graph
  let graph = new Graph();

  // Add the Vertices
  _addGraphVertices(db, graph, function(err, graph) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }

    // Add Graph Edges
    _addGraphEdges(db, graph, function(err, graph) {

      // Database Query Error
      if ( err ) {
        return callback(err);
      }

      // Return the finished graph
      cache_graph.put(cacheKey, graph);
      return callback(null, graph);

    });

  });

}
function buildGraph(db, callback) {

  // Check cache for graph
  let cacheKey = db.id + "-graph";
  let cache = cache_graph.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }

  // Build Graph
  let graph = new Graph();

  // Add the Vertices
  _addGraphVertices(db, graph, function(err, graph) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }

    // Add Graph Edges
    _addGraphEdges(db, graph, function(err, graph) {

      // Database Query Error
      if ( err ) {
        return callback(err);
      }

      // Return the finished graph
      cache_graph.put(cacheKey, graph);
      return callback(null, graph);

    });

  });

}
function buildGraph ( db , callback ) { // Check cache for graph let cacheKey = db . id + "-graph" ; let cache = cache_graph . get ( cacheKey ) ; if ( cache !== null ) { return callback ( null , cache ) ; } // Build Graph let graph = new Graph ( ) ; // Add the Vertices _addGraphVertices ( db , graph , function ( err , graph ) { // Database Query Error if ( err ) { return callback ( err ) ; } // Add Graph Edges _addGraphEdges ( db , graph , function ( err , graph ) { // Database Query Error if ( err ) { return callback ( err ) ; } // Return the finished graph cache_graph . put ( cacheKey , graph ) ; return callback ( null , graph ) ; } ) ; } ) ; }
Build the entire Agency Line Graph
@param {RightTrackDB} db The Right Track DB to query
@param {function} callback Callback function
@param {Error} callback.err Database Query Error
@param {Graph} [callback.graph] Agency Graph
@see {@link https://www.npmjs.com/package/graph.js|graph.js package}
Build the entire Agency Line Graph