todo make separate method for graphData in future
501536
public static List<ProducerDecoratorBean> getDecoratedProducers(HttpServletRequest req, List<ProducerAO> producers, Map<String, GraphDataBean> graphData){

        Map<IDecorator, List<ProducerAO>> decoratorMap = new HashMap<>(producers.size());
        for (ProducerAO producer : producers){
            try{
                IDecorator decorator = findOrCreateDecorator(producer);
                List<ProducerAO> decoratedProducers = decoratorMap.get(decorator);
                if (decoratedProducers == null){
                    decoratedProducers = new ArrayList<>();
                    decoratorMap.put(decorator, decoratedProducers);

                    for(StatValueAO statBean : producer.getFirstStatsValues()){
                        String graphKey = decorator.getName()+ '_' +statBean.getName();
                        GraphDataBean graphDataBean = new GraphDataBean(decorator.getName()+ '_' +statBean.getJsVariableName(), statBean.getName());
                        graphData.put(graphKey, graphDataBean);
                    }
                }
                decoratedProducers.add(producer);
            }catch(IndexOutOfBoundsException e){
                //producer has no stats at all, ignoring
            }
        }

        Set<Map.Entry<IDecorator, List<ProducerAO>>> entries = decoratorMap.entrySet();
        List<ProducerDecoratorBean> beans = new ArrayList<>(entries.size());
        for (Map.Entry<IDecorator, List<ProducerAO>> entry : entries){
            IDecorator decorator = entry.getKey();
            ProducerDecoratorBean b = new ProducerDecoratorBean();
            b.setName(decorator.getName());
            b.setCaptions(decorator.getCaptions());

            for (ProducerAO p : entry.getValue()) {
                try {
                    List<StatValueAO> values = p.getFirstStatsValues();
                    for (StatValueAO valueBean : values){
                        String graphKey = decorator.getName()+ '_' +valueBean.getName();
                        GraphDataBean bean = graphData.get(graphKey);
                        if (bean==null) {
                            // FIXME!
                            log.warn("unable to find bean for key: " + graphKey);
                        } else {
                            bean.addValue(new GraphDataValueBean(p.getProducerId(), valueBean.getRawValue()));
                        }
                    }
                }catch(UnknownIntervalException e){
                    //do nothing, apparently we have a decorator which has no interval support for THIS interval.
                }
            }
            b.setProducerBeans(StaticQuickSorter.sort(decoratorMap.get(decorator), getProducerBeanSortType(b, req)));
            beans.add(b);
        }

        return beans;
    }
1133802
public static <K, EV> Graph<K, NullValue, EV> fromDataSet(
			DataSet<Edge<K, EV>> edges, ExecutionEnvironment context) {

		DataSet<Vertex<K, NullValue>> vertices = edges
			.flatMap(new EmitSrcAndTarget<>())
				.name("Source and target IDs")
			.distinct()
				.name("IDs");

		return new Graph<>(vertices, edges, context);
	}
1130359
function savePrettyGraphSONSync(graph, filename) {
        // Build the GraphSON in memory in Java.
        var ByteArrayOutputStream = Tinkerpop.autoImport('ByteArrayOutputStream');
        var stream = new ByteArrayOutputStream();
        var builder = Tinkerpop.GraphSONWriter.build();
        var mapper = _newGraphSONMapperSync();
        builder.mapper(mapper);
        var writer = builder.create();
        writer.writeGraph(stream, graph);
        // Beautify the JSON.
        var uglyString = stream.toString();
        var prettyString = _prettyGraphSONString(uglyString);
        // Write to the file.
        fs.writeFileSync(filename, prettyString);
        return graph;
    }
889251
@Override
    public void onCreate() {
        super.onCreate();

        graphMonitor = new Graph.Monitor() {
            @Override
            public void onInject(Object target) {
                if (controller != null && target == MvcService.this) {
                    controller.view = MvcService.this;
                }
            }

            @Override
            public void onRelease(Object target) {

            }
        };
        Mvc.graph().registerMonitor(graphMonitor);

        if (getControllerClass() != null) {
            try {
                controller = Mvc.graph().reference(getControllerClass(), null);
            } catch (CircularDependenciesException e) {
                e.printStackTrace();
            } catch (ProvideException e) {
                e.printStackTrace();
            } catch (ProviderMissingException e) {
                throw new IllegalStateException("Unable to inject "
                        + getControllerClass().getName() + ".\n" + e.getMessage(), e);
            }
        }

        Mvc.graph().inject(this);

        eventRegister = new EventRegister(this);
        eventRegister.registerEventBuses();
    }
281053
@Override
    protected void onGraphDraw(Canvas _Canvas) {
        super.onGraphDraw(_Canvas);
        _Canvas.translate(-mCurrentViewport.left, -mCurrentViewport.top);
        drawBars(_Canvas);
    }
994365
function graph(g) {
    init(g);

    var xs = [upperLeft(g), upperRight(g), lowerRight(g), lowerLeft(g)];

    g.nodes().forEach(function(u) {
      var xArray = [];
      for (var i = 0; i < xs.length; ++i) {
        xArray.push(xs[i][u]);
      }
      xArray.sort();
      g.node(u).x = (xArray[1] + xArray[2]) / 2;
    });
  }
742114
function createDependencyGraph(tasks) {
    var graph = {
      tasks: {},
      roots: [],
      leaves: [],
      resources: [],
      depth: 0,
      end : 0
    };

    for(var i = 0, len = tasks.length; i < len; i++) {
      var t = tasks[i];
      graph.tasks[t.id] = {
        id: t.id,
        duration: t.duration,
        priority: t.priority,
        schedule: t.schedule,
        minSchedule: t.minSchedule,
        dependsOn: t.dependsOn,
        resources: t.resources
      };
    }

    setResources(graph);
    setRequiredBy(graph.tasks);
    setRootsAndLeaves(graph);

    setDepth(graph, graph.leaves, 0);
    graph.depth += 1; // increment depth so it is 1 based

    forwardPass(graph, {}, graph.roots, 0);
    setEnd(graph, graph.leaves);
    backwardPass(graph, {}, graph.leaves, graph.end);

    return graph;
  }
1062136
public static <K, VV, EV> Graph<K, VV, EV> fromDataSet(DataSet<Vertex<K, VV>> vertices,
			DataSet<Edge<K, EV>> edges, ExecutionEnvironment context) {

		return new Graph<>(vertices, edges, context);
	}
1306301
private void convertNode(final GraphObjectMap map, final Node node) {

		final NodeList nodeList = node.getChildNodes();
		if (nodeList != null) {

			final List<GraphObjectMap> children = new LinkedList<>();
			final int length                    = nodeList.getLength();

			for (int i=0; i<length; i++) {

				final GraphObjectMap childMap = new GraphObjectMap();
				final Node childNode          = nodeList.item(i);

				convertNode(childMap, childNode);
				children.add(childMap);
			}

			map.put(childrenProperty, children);
		}

		final NamedNodeMap attributeList = node.getAttributes();
		if (attributeList != null) {

			final List<GraphObjectMap> attributes = new LinkedList<>();
			final int length                      = attributeList.getLength();

			for (int i=0; i<length; i++) {

				final GraphObjectMap attributeMap = new GraphObjectMap();
				final Node attributeNode          = attributeList.item(i);

				convertNode(attributeMap, attributeNode);
				attributes.add(attributeMap);
			}

			map.put(attributesProperty, attributes);
		}

		map.put(typeProperty, node.getClass().getSimpleName());

		final String nodeName = node.getNodeName();
		if (nodeName != null) {

			map.put(nameProperty, nodeName);
		}

		final String nodeValue = node.getNodeValue();
		if (nodeValue != null) {

			map.put(valueProperty, nodeValue);
		}
	}
1247400
function () {
        var data = this.data;
        var nodes = this._nodes;

        for (var i = 0, len = nodes.length; i < len; i++) {
            nodes[i].dataIndex = -1;
        }

        for (var i = 0, len = data.count(); i < len; i++) {
            nodes[data.getRawIndex(i)].dataIndex = i;
        }
    }
1144665
function _newGraphSONMapperSync() {
        var builder = Tinkerpop.GraphSONMapper.build();
        builder.embedTypes(true);
        var mapper = builder.create();
        return mapper;
    }
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;
				}
			}
		}
	}
110778
function (vertex, data) {
        return InputDataNode.create(Ember.$.extend(data, {
          treeParent: vertex,
          vertex: vertex
        }));
      }
1297494
@JavaScriptMethod
    public JSONObject getGraphData() {
        JSONObject projectDataSet = new JSONObject();
        if (_projectResult == null) {
//            getUpdatedData();
            return new JSONObject();
        }


        for (SortedMap.Entry<String, LrProjectScenarioResults> scenarioResults : _projectResult.getScenarioResults()
                .entrySet()) {

            JSONObject scenarioData = new JSONObject();
            JSONObject scenarioStats = new JSONObject();
            //            LrGraphUtils
            //                    .constructVuserSummary(scenarioResults.getValue().getvUserSummary(), scenarioStats, _workedBuilds
            //                            .size());
            //            LrGraphUtils.constructDurationSummary(scenarioResults.getValue().getDurationData(), scenarioStats);
            //            LrGraphUtils.constructConnectionSummary(scenarioResults.getValue().getMaxConnectionsCount(), scenarioStats);
            //            LrGraphUtils.constructTransactionSummary(scenarioResults.getValue().getTransactionSum(), scenarioStats,
            //                    _workedBuilds.size());


            scenarioData.put("scenarioStats", scenarioStats);

            JSONObject scenarioGraphData = new JSONObject();
            //Scenario data graphs
//            LrGraphUtils.constructVuserGraph(scenarioResults, scenarioGraphData);
//            LrGraphUtils.constructConnectionsGraph(scenarioResults, scenarioGraphData);
            //Scenario SLA graphs
            LrGraphUtils.constructTotalHitsGraph(scenarioResults, scenarioGraphData);
            LrGraphUtils.constructAvgHitsGraph(scenarioResults, scenarioGraphData);
            LrGraphUtils.constructTotalThroughputGraph(scenarioResults, scenarioGraphData);
            LrGraphUtils.constructAverageThroughput(scenarioResults, scenarioGraphData);
            LrGraphUtils.constructErrorGraph(scenarioResults, scenarioGraphData);
            LrGraphUtils.constructAvgTransactionGraph(scenarioResults, scenarioGraphData);
            LrGraphUtils.constructPercentileTransactionGraph(scenarioResults, scenarioGraphData);

            scenarioData.put("scenarioData", scenarioGraphData);

            String scenarioName = scenarioResults.getKey();
            projectDataSet.put(scenarioName, scenarioData);
        }
        return projectDataSet;
    }
1131363
public static <K, VV, EV> Graph<K, VV, EV> fromCollection(Collection<Vertex<K, VV>> vertices,
			Collection<Edge<K, EV>> edges, ExecutionEnvironment context) {

		return fromDataSet(context.fromCollection(vertices),
				context.fromCollection(edges), context);
	}
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(',');
  }
877537
public static <K, EV> Graph<K, NullValue, EV> fromCollection(Collection<Edge<K, EV>> edges,
			ExecutionEnvironment context) {

		return fromDataSet(context.fromCollection(edges), context);
	}