Skip to content
Browse files

Merge branch 'master' of https://github.com/Raibaz/sigma.js into devel

  • Loading branch information...
2 parents cd71892 + dd5fdcb commit ebc05e1a9c50e831ce3708e60e194712b82efdab @jacomyal committed Mar 27, 2012
Showing with 23 additions and 9 deletions.
  1. +2 −1 plugins/sigma.parseGexf.js
  2. +14 −3 src/core/graph.js
  3. +5 −3 src/core/plotter.js
  4. +2 −2 src/core/sigmapublic.js
View
3 plugins/sigma.parseGexf.js
@@ -131,6 +131,7 @@ sigma.publicPrototype.parseGexf = function(gexfPath) {
var source = edgeNode.getAttribute('source');
var target = edgeNode.getAttribute('target');
var label = edgeNode.getAttribute('label');
+ var weight_val = parseFloat(edgeNode.getAttribute('weight'));
var edge = {id:j, sourceID:source, targetID:target,label:label, attributes:[]};
var attvalueNodes = edgeNode.getElementsByTagName('attvalue');
for(k=0; k<attvalueNodes.length; k++){
@@ -140,7 +141,7 @@ sigma.publicPrototype.parseGexf = function(gexfPath) {
edge.attributes.push({attr:attr, val:val});
}
- sigmaInstance.addEdge(edgeId++,source,target,edge);
+ sigmaInstance.addEdge(edgeId++,source,target,edge,weight_val);
}
}
};
View
17 src/core/graph.js
@@ -223,7 +223,7 @@ function Graph() {
* of the edge.
* @return {Graph} Returns itself.
*/
- function addEdge(id, source, target, params) {
+ function addEdge(id, source, target, params, weight) {
if (self.edgesIndex[id]) {
throw new Error('Edge "' + id + '" already exists.');
}
@@ -238,16 +238,21 @@ function Graph() {
throw new Error(s);
}
+ if(!weight) {
+ weight = 1;
+ }
+
params = params || {};
var e = {
'source': self.nodesIndex[source],
'target': self.nodesIndex[target],
'size': 1,
- 'weight': 1,
+ 'weight': weight,
'displaySize': 0.5,
'label': id.toString(),
'id': id.toString(),
- 'attr': {}
+ 'attr': {},
+ 'hidden': false
};
e['source']['degree']++;
@@ -261,6 +266,9 @@ function Graph() {
case 'source':
case 'target':
break;
+ case 'hidden':
+ e[k] = !!params[k];
+ break;
case 'size':
e[k] = +params[k];
break;
@@ -328,6 +336,9 @@ function Graph() {
case 'target':
edge[k] = self.nodesIndex[k] || edge[k];
break;
+ case 'hidden':
+ edge[k] = !!copy[k];
+ break;
case 'color':
case 'label':
case 'type':
View
8 src/core/plotter.js
@@ -207,9 +207,11 @@ function Plotter(nodesCtx, edgesCtx, labelsCtx, hoverCtx, graph, w, h) {
var s, t, i = 0;
while (i++< self.p.edgesSpeed && self.currentEdgeIndex < c) {
- s = graph.edges[self.currentEdgeIndex]['source'];
- t = graph.edges[self.currentEdgeIndex]['target'];
- if (s['hidden'] ||
+ e = graph.edges[self.currentEdgeIndex];
+ s = e['source'];
+ t = e['target'];
+ if (e['hidden'] ||
+ s['hidden'] ||
t['hidden'] ||
(!self.isOnScreen(s) && !self.isOnScreen(t))) {
self.currentEdgeIndex++;
View
4 src/core/sigmapublic.js
@@ -124,8 +124,8 @@ function SigmaPublic(sigmaInstance) {
return self;
};
- this.addEdge = function(id, source, target, params) {
- s.graph.addEdge(id, source, target, params);
+ this.addEdge = function(id, source, target, params, weight) {
+ s.graph.addEdge(id, source, target, params, weight);
return self;
}

0 comments on commit ebc05e1

Please sign in to comment.
Something went wrong with that request. Please try again.