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

  // Counters
  let done = 0;
  let count = graph.vertexCount();

  // Loop through each Vertex in the Graph
  for ( let [stopId, stop] of graph ) {

    // Get the Edges for the Vertex
    _getStopEdges(db, stopId, function(err, edges) {

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

      // Add each edge to the Graph
      for ( let i = 0; i < edges.length; i++ ) {
        graph.ensureEdge(stopId, edges[i]);
        graph.ensureEdge(edges[i], stopId);
      }

      // Finish the Vertex
      _finish();

    });

  }

  // Keep track of finished vertices
  function _finish() {
    done++;
    if ( done === count ) {
      return callback(null, graph);
    }
  }

}
function _addGraphEdges(db, graph, callback) {

  // Counters
  let done = 0;
  let count = graph.vertexCount();

  // Loop through each Vertex in the Graph
  for ( let [stopId, stop] of graph ) {

    // Get the Edges for the Vertex
    _getStopEdges(db, stopId, function(err, edges) {

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

      // Add each edge to the Graph
      for ( let i = 0; i < edges.length; i++ ) {
        graph.ensureEdge(stopId, edges[i]);
        graph.ensureEdge(edges[i], stopId);
      }

      // Finish the Vertex
      _finish();

    });

  }

  // Keep track of finished vertices
  function _finish() {
    done++;
    if ( done === count ) {
      return callback(null, graph);
    }
  }

}
function _addGraphEdges ( db , graph , callback ) { // Counters let done = 0 ; let count = graph . vertexCount ( ) ; // Loop through each Vertex in the Graph for ( let [ stopId , stop ] of graph ) { // Get the Edges for the Vertex _getStopEdges ( db , stopId , function ( err , edges ) { // Database Query Error if ( err ) { return callback ( err ) ; } // Add each edge to the Graph for ( let i = 0 ; i < edges . length ; i ++ ) { graph . ensureEdge ( stopId , edges [ i ] ) ; graph . ensureEdge ( edges [ i ] , stopId ) ; } // Finish the Vertex _finish ( ) ; } ) ; } // Keep track of finished vertices function _finish ( ) { done ++ ; if ( done === count ) { return callback ( null , graph ) ; } } }
Add edges to each Vertex in the Graph
@param {RightTrackDB} db The Right Track DB to query
@param {Graph} graph The Graph to add edges to
@param {function} callback Callback function(err, graph)
@private
Add edges to each Vertex in the Graph