Revert mixed argument patch for addNode(), because
addNodes() in loadJSON already supports single string argument.
This commit is contained in:
		
							parent
							
								
									1b93bd7dc7
								
							
						
					
					
						commit
						adebe2dab0
					
				
							
								
								
									
										15
									
								
								springy.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								springy.js
									
									
									
									
									
								
							| 
						 | 
					@ -61,14 +61,7 @@ var Edge = function(id, source, target, data) {
 | 
				
			||||||
//   	this.data.type
 | 
					//   	this.data.type
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Graph.prototype.addNode = function(mixed) {
 | 
					Graph.prototype.addNode = function(node) {
 | 
				
			||||||
	// mixed can be Node object or a string
 | 
					 | 
				
			||||||
	var node;
 | 
					 | 
				
			||||||
	if (typeof mixed == "string" || mixed instanceof String) {
 | 
					 | 
				
			||||||
		node = new Node(mixed, {label:mixed});
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		node = mixed;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (!(node.id in this.nodeSet)) {
 | 
						if (!(node.id in this.nodeSet)) {
 | 
				
			||||||
		this.nodes.push(node);
 | 
							this.nodes.push(node);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -83,7 +76,9 @@ Graph.prototype.addNodes = function() {
 | 
				
			||||||
        // accepts variable number of arguments, where each argument
 | 
					        // accepts variable number of arguments, where each argument
 | 
				
			||||||
        // is a string that becomes both node identifier and label
 | 
					        // is a string that becomes both node identifier and label
 | 
				
			||||||
        for (var i = 0; i < arguments.length; i++) {
 | 
					        for (var i = 0; i < arguments.length; i++) {
 | 
				
			||||||
                this.addNode(arguments[i]);
 | 
					                var name = arguments[i];
 | 
				
			||||||
 | 
					                var node = new Node(name, {label:name});
 | 
				
			||||||
 | 
					                this.addNode(node);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -177,7 +172,7 @@ of nodes and edges:
 | 
				
			||||||
	if ('nodes' in json && 'edges' in json) {
 | 
						if ('nodes' in json && 'edges' in json) {
 | 
				
			||||||
		var graph = this;
 | 
							var graph = this;
 | 
				
			||||||
		json['nodes'].forEach(function(name) {
 | 
							json['nodes'].forEach(function(name) {
 | 
				
			||||||
			graph.addNode(name);
 | 
								graph.addNodes(name);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		json['edges'].forEach(function(pair) {
 | 
							json['edges'].forEach(function(pair) {
 | 
				
			||||||
			graph.addEdges(pair);
 | 
								graph.addEdges(pair);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user