Add all Stops as Vertices to the Graph
@param {RightTrackDB} db The Right Track DB to query
@param {Graph} graph The Graph to add vertices to
@param {function} callback Callback function(err, graph)
@private
507166
function _addGraphVertices(db, graph, callback) {

  // Get all Stops
  StopsTable.getStops(db, function(err, stops) {

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

    // Add each Stop as a Vertex
    for ( let i = 0; i < stops.length; i++ ) {
      graph.addNewVertex(stops[i].id, stops[i]);
    }

    // Return the Graph
    return callback(null, graph);

  });

}
26060
function (connectionName, callback) {
        var self = this,
            conn = self.connection();

        // if not yet connected, spawn new connection and initiate transaction
        if (!conn) {
            self.connect(connectionName, function (error, conn) {
                if (error) {
                    callback(error, conn);
                    return;
                }
                // now that we have the connection, we initiate transaction. note that this sql_start is part of the new
                // connection branch. it is always highly likely that this would be the program flow. in a very unlikely
                // case the alternate flow will kick in, which is the `conn.query` right after this if-block.
                conn.beginTransaction(function (error) {
                    callback(error, self);
                });
            });

            return; // do not proceed with sql_start if connection wasn't initially present.
        }

        // if transaction is attempted across multiple connections, return an error
        if (connectionName !== self._connectionName) {
            return callback(new AdapterError(AdapterError.TRANSACTION_MULTI_DB_CONNECTION_ATTEMPTED));
        }

        conn.beginTransaction(function (error) {
            // if callback mode is used, then execute it and send self as a parameter to match the new Constructor API.
            callback(error, self);
        });
    }
1003484
function (graph, opts, params) {
    var self = this;
    var updatedNodes = graph.allNodes;
    if (opts.restrictToComp) {
      updatedNodes = graph.allNodes.filter(function(node) {
        return node.comp && node.comp.name == opts.restrictToComp;
      });
    }

    function assign(statements, varName, hash) {
      params[varName] = hash;
      if (opts.additive) {
        _.forEach(hash, function(val, key) {
          statements.push(varName + '.`' + key + '`={' + varName + '}.`' + key + '`');
        });
      } else {
        statements.push(varName + '={' + varName + '}');
      }
    }

    return 'SET ' + updatedNodes.reduce(function(statements, node) {
      // set props
      var props = node.props;
      if (props[self.db.options.id]) props = _.omit(props, self.db.options.id);
      
      if (node.comp) assign(statements, '__rel_' + node.name, props._rel || {});
      
      props = _.omit(props, '_rel');
      assign(statements, node.name, props);

      // set timestamps
      if (!node.model.usingTimestamps) return statements;
      statements.push(getSetCreatedTimestampStatement(node));
      statements.push(node.name + '.' + node.model.updatedField + ' = timestamp()');

      return statements;
    }, []).join(',');
  }
1345553
private void populateGraph(final EntityGraph<?> graph, final Set<String> fetches)
	{
		Map<String, Subgraph<?>> created = new HashMap<>();

		for (String fetch : fetches)
		{
			final String[] parts = StringUtils.split(fetch, '.');

			// Starts of null (meaning parent is the root graph), updated as we go through path segments to refer to the last path segment
			Subgraph<?> parent = null;

			// Iterate over the path segments, adding attributes subgraphs
			for (int i = 0; i < parts.length; i++)
			{
				final String path = StringUtils.join(parts, '.', 0, i + 1);
				final boolean isLeaf = (i == parts.length - 1);

				final Subgraph<?> existing = created.get(path);

				if (existing == null)
				{
					if (parent == null)
					{
						try
						{
							// Relation under root
							graph.addAttributeNodes(parts[i]);

							// Only set up a subgraph if this is not a leaf node
							// This prevents us trying to add a Subgraph for a List of Embeddable
							if (!isLeaf)
								parent = graph.addSubgraph(parts[i]);
						}
						catch (IllegalArgumentException e)
						{
							throw new IllegalArgumentException("Error adding graph member " +
							                                   parts[i] +
							                                   " with isLeaf=" +
							                                   isLeaf +
							                                   " to root as part of " +
							                                   fetch, e);
						}
					}
					else
					{
						try
						{
							// Relation under parent
							parent.addAttributeNodes(parts[i]);

							// Only set up a subgraph if this is not a leaf node
							// This prevents us trying to add a Subgraph for a List of Embeddable
							if (!isLeaf)
								parent = parent.addSubgraph(parts[i]);
						}
						catch (IllegalArgumentException e)
						{
							throw new IllegalArgumentException("Error adding graph member " +
							                                   parts[i] +
							                                   " with isLeaf=" +
							                                   isLeaf +
							                                   " as part of " +
							                                   fetch +
							                                   " with parent.class=" +
							                                   parent.getClassType(), e);
						}
					}

					if (!isLeaf)
						created.put(path, parent);
				}
				else
				{
					// Already seen this graph node before
					parent = existing;
				}
			}
		}
	}
477391
function(node, callback) {
    if (node.firstViewNode) node = node.firstViewNode;

    this.animateNode('out', node, callback);
  }
537166
function loadGraphSON(graph, filename, callback) {
        var FileInputStream = Tinkerpop.autoImport('FileInputStream');
        var stream = new FileInputStream(filename);
        return Tinkerpop.GraphSONReader.buildP()
            .then(function (builder) {
            return _newGraphSONMapper()
                .then(function (mapper) { return builder.mapperP(mapper); });
        })
            .then(function (builder) { return builder.createP(); })
            .then(function (reader) { return reader.readGraphP(stream, graph); })
            .then(function () { return graph; })
            .nodeify(callback);
    }
532242
function _queryForStopByName(db, query, callback) {

  // Perform the search query
  db.get(query, function(err, result) {

    // No stop found, return undefined
    if ( result === undefined ) {
      return callback(undefined);
    }

    // Stop found, return the Stop from it's ID
    getStop(db, result.stop_id, function(err, stop) {
      return callback(stop);
    });

  });

}
1125937
public void createTransitions( GraphImpl graph, Tree<Row> pointer ){
        Row row = pointer.getContent();
        Element mainToken = row.getMainElement();
        Type type = mainToken.getType();
        Tree<Row> next;
        switch( type ) {
            case START:
            case END:
                return;
            case VALUE:
            case CALL:
            case CALL_ASYNC:
            case HUMAN_TASK:
            case WAIT_SIGNAL:
            case WAIT_TIMER:
            case WAIT_UNTIL_DATE:
            case CREATE_INSTANCE:
            case VALIDATE_INPUT_VARIABLE:
            case ESCALATE:
            case JOIN_FIRST:
            case JOIN_ALL:
                next = findNext( pointer );
                if( next != null ){
                    addTransition( graph, pointer, next );
                }
                return;
            case WHILE_DO_BEGIN:
                // transition for loop entry
                next = pointer.hasChildren() ? pointer.getFirstChild() : pointer.getNext();
                addConditionalTransition( graph, pointer, next, pointer );
                // transition for loop exit
                Tree<Row> whileDoEnd = pointer.getNext();
                next = findNext( whileDoEnd );
                if( next != null ){
                    addConditionalTransition( graph, pointer, next, null );
                }
                return;
            case WHILE_DO_END:
                // transition to loop begin
                Tree<Row> whileDoBegin = pointer.getPrevious();
                addTransition( graph, pointer, whileDoBegin );
                return;
            case DO_WHILE_BEGIN:
                next = pointer.hasChildren() ? pointer.getFirstChild() : pointer.getNext();
                addTransition( graph, pointer, next );
                return;
            case DO_WHILE_END:
                // transition to loop begin
                Tree<Row> doWhileBegin = pointer.getPrevious();
                addConditionalTransition( graph, pointer, doWhileBegin, pointer );
                // transition to next
                next = findNext( pointer );
                if( next != null ){
                    addConditionalTransition( graph, pointer, next, null );
                }
                return;
            case IF:
                next = pointer.hasChildren() ? pointer.getFirstChild() : findEndIf( pointer );
                addConditionalTransition( graph, pointer, next, pointer );
                return;
            case ELSE_IF:
                next = pointer.hasChildren() ? pointer.getFirstChild() : findEndIf( pointer );
                addConditionalTransition( graph, findIf( pointer ), next, pointer );
                return;
            case ELSE:
                next = pointer.hasChildren() ? pointer.getFirstChild() : findEndIf( pointer );
                addConditionalTransition( graph, findIf( pointer ), next, null );
                return;
            case END_IF:
                // adding empty ELSE if no such block was given
                if( !Type.ELSE.equals( pointer.getPrevious().getContent().getType() ) ){
                    addConditionalTransition( graph, findIf( pointer ), pointer, null );
                }
                // transition to next
                next = findNext( pointer );
                if( next != null ){
                    addTransition( graph, pointer, next );
                }
                return;
            case SPLIT:
                return;
            case BRANCH:
                Tree<Row> split = pointer.getParent();
                next = pointer.hasChildren() ? pointer.getFirstChild() : split.getNext();
                if( isOrFork( split ) ){
                    addConditionalTransition( graph, split, next, pointer );
                }
                else{
                    addNamedTransition( graph, split, next );
                }
                return;
            default :
                throw new IllegalStateException();
        }
    }
151762
function parseDB(callback) {
    pgStructure(getConfig('database.host'), getConfig('database.database'), getConfig('database.user'),
        getConfig('database.password'), { port: getConfig('database.port'), schema: getConfig('database.schema') },
        callback);
}
1169540
function (node, callback) {
			// important note!
			// starts paused
			//
			var bHandle = on(node.ownerDocument.documentElement, 'click', function (e) {
				var target = e.target;
				if (target.nodeType !== 1) {
					target = target.parentNode;
				}
				if (target && !node.contains(target)) {
					callback(e);
				}
			});

			var handle = {
				state: 'resumed',
				resume: function () {
					setTimeout(function () {
						bHandle.resume();
					}, 100);
					this.state = 'resumed';
				},
				pause: function () {
					bHandle.pause();
					this.state = 'paused';
				},
				remove: function () {
					bHandle.remove();
					this.state = 'removed';
				}
			};
			handle.pause();

			return handle;
		}
1223972
function(kgraph) {
        if (kgraph) {
          zoomToFit(kgraph);
          // assign coordinates to nodes
          kgraph.children.forEach(function(n) {
            var d3node = nodes[parseInt(n.id)];
            copyProps(n, d3node);
            (n.ports || []).forEach(function(p, i) {
              copyProps(p, d3node.ports[i]);
            });
            (n.labels || []).forEach(function(l, i) {
              copyProps(l, d3node.labels[i]);
            });
          });
          // edges
          kgraph.edges.forEach(function(e) {
            var l = links[parseInt(e.id) - nodes.length];
            copyProps(e, l);
            copyProps(e.source, l.source);
  	        copyProps(e.target, l.target);
            // make sure the bendpoint array is valid
            l.bendPoints = e.bendPoints || [];
          });
        }
        function copyProps(src, tgt, copyKeys) {
          var keys = kgraphKeys;
          if (copyKeys) {
            keys = copyKeys.reduce(function (p, c) {p[c] = 1; return p;}, {});
          }
          for (var k in src) {
            if (keys[k]) {
              tgt[k] = src[k];
            }
          }
        }
        // invoke the 'finish' event
        dispatch.finish({graph: kgraph});
      }
945457
function saveGraphSON(graph, filename, callback) {
        var FileOutputStream = Tinkerpop.autoImport('FileOutputStream');
        var stream = new FileOutputStream(filename);
        return Tinkerpop.GraphSONWriter.buildP()
            .then(function (builder) {
            return _newGraphSONMapper()
                .then(function (mapper) { return builder.mapperP(mapper); });
        })
            .then(function (builder) { return builder.createP(); })
            .then(function (writer) { return writer.writeGraphP(stream, graph); })
            .then(function () { return graph; })
            .nodeify(callback);
    }
536964
function (db, query, callback) {
    // query parameter is optional
    if (!callback) {
      callback = query
      query = {}
    }

    // create a new request object
    var req = {
      // db name
      db: db,
      // authenticated url to db
      db_url: url.resolve(couch_url, encodeURIComponent(db)),
      // used by the update queue workers
      callback: callback,
      // store the query parameters
      query: query
    }

    // make sure the request has a since parameter set
    exports.updateSince(req, function (err, req) {
      if (err) {
        return callback(err)
      }

      // add the changes request to the pool
      exports.addToPool(idle, req)
    // queue the new request for immediate update
    // exports.refreshDB(updated, idle, db)
    })
  }
1098061
function(params, cb) {
		var res = 0;
		// CREATE VERTEX without parameters
		var db = alasql.databases[dbid];
		var edge = {$id: db.counter++, $node: 'EDGE'};
		var v1 = fromfn(params, alasql);
		var v2 = tofn(params, alasql);
		// Set link
		edge.$in = [v1.$id];
		edge.$out = [v2.$id];
		// Set sides
		if (typeof v1.$out === 'undefined') {
			v1.$out = [];
		}
		v1.$out.push(edge.$id);

		if (typeof v2.$in === 'undefined') {
			v2.$in = [];
		}
		v2.$in.push(edge.$id);
		// Save in objects
		db.objects[edge.$id] = edge;
		res = edge;
		if (namefn) {
			namefn(edge);
		}
		if (setfn) {
			setfn(edge, params, alasql);
		}

		if (cb) {
			res = cb(res);
		}
		return res;
	}
1248896
function () {
		var series = this,
			graphPath = [],
			segmentPath,
			singlePoints = []; // used in drawTracker

		// Divide into segments and build graph and area paths
		each(series.segments, function (segment) {
			
			segmentPath = series.getSegmentPath(segment);
			
			// add the segment to the graph, or a single point for tracking
			if (segment.length > 1) {
				graphPath = graphPath.concat(segmentPath);
			} else {
				singlePoints.push(segment[0]);
			}
		});

		// Record it for use in drawGraph and drawTracker, and return graphPath
		series.singlePoints = singlePoints;
		series.graphPath = graphPath;
		
		return graphPath;
		
	}
1170861
function GraphProgress(graph, graphDescription) {
        assert.object(graph, 'graph');
        assert.string(graphDescription, 'graphDescription');

        this.graph = graph;
        this.data = {
            graphId: graph.instanceId,
            nodeId: graph.node,
            graphName: graph.name || 'Not available',
            status: graph._status,
            progress: {
                description: graphDescription || 'Not available',
            }
        };
        this._calculateGraphProgress();
    }
143544
function query(){
		//console.log(arguments[0]);
		var self = this;
		var args = arguments;
		var last_arg = args[args.length - 1];
		var bHasCallback = (typeof last_arg === 'function');
		if (!bHasCallback) // no callback
			last_arg = function(){};

		var count_arguments_without_callback = bHasCallback ? (args.length-1) : args.length;
		var new_args = [];

		for (var i=0; i<count_arguments_without_callback; i++) // except callback
			new_args.push(args[i]);
		if (!bHasCallback && !bCordova)
			return new Promise(function(resolve){
				new_args.push(resolve);
				self.query.apply(self, new_args);
			});
		takeConnectionFromPool(function(connection){
			// add callback that releases the connection before calling the supplied callback
			new_args.push(function(rows){
				connection.release();
				last_arg(rows);
			});
			connection.query.apply(connection, new_args);
		});
	}