|
@ -1,21 +1,21 @@ |
|
|
|
|
|
|
|
|
function parseGephi(gephiJSON, options) { |
|
|
|
|
|
|
|
|
function parseGephi(gephiJSON, optionsObj) { |
|
|
var edges = []; |
|
|
var edges = []; |
|
|
var nodes = []; |
|
|
var nodes = []; |
|
|
this.options = { |
|
|
|
|
|
|
|
|
var options = { |
|
|
edges: { |
|
|
edges: { |
|
|
inheritColor: true |
|
|
inheritColor: true |
|
|
}, |
|
|
}, |
|
|
nodes: { |
|
|
nodes: { |
|
|
allowedToMove: false, |
|
|
|
|
|
|
|
|
fixed: false, |
|
|
parseColor: false |
|
|
parseColor: false |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (options !== undefined) { |
|
|
if (options !== undefined) { |
|
|
this.options.nodes['allowedToMove'] = options.allowedToMove | false; |
|
|
|
|
|
this.options.nodes['parseColor'] = options.parseColor | false; |
|
|
|
|
|
this.options.edges['inheritColor'] = options.inheritColor | true; |
|
|
|
|
|
|
|
|
options.nodes['fixed'] = optionsObj.fixed !== undefined ? options.fixed : false; |
|
|
|
|
|
options.nodes['parseColor'] = optionsObj.parseColor !== undefined ? options.parseColor : false; |
|
|
|
|
|
options.edges['inheritColor'] = optionsObj.inheritColor !== undefined ? options.inheritColor : true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var gEdges = gephiJSON.edges; |
|
|
var gEdges = gephiJSON.edges; |
|
@ -30,7 +30,7 @@ function parseGephi(gephiJSON, options) { |
|
|
// edge['value'] = gEdge.attributes !== undefined ? gEdge.attributes.Weight : undefined;
|
|
|
// edge['value'] = gEdge.attributes !== undefined ? gEdge.attributes.Weight : undefined;
|
|
|
// edge['width'] = edge['value'] !== undefined ? undefined : edgegEdge.size;
|
|
|
// edge['width'] = edge['value'] !== undefined ? undefined : edgegEdge.size;
|
|
|
edge['color'] = gEdge.color; |
|
|
edge['color'] = gEdge.color; |
|
|
edge['inheritColor'] = edge['color'] !== undefined ? false : this.options.inheritColor; |
|
|
|
|
|
|
|
|
edge['inheritColor'] = edge['color'] !== undefined ? false : options.inheritColor; |
|
|
edges.push(edge); |
|
|
edges.push(edge); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -39,18 +39,18 @@ function parseGephi(gephiJSON, options) { |
|
|
var gNode = gNodes[i]; |
|
|
var gNode = gNodes[i]; |
|
|
node['id'] = gNode.id; |
|
|
node['id'] = gNode.id; |
|
|
node['attributes'] = gNode.attributes; |
|
|
node['attributes'] = gNode.attributes; |
|
|
|
|
|
node['title'] = gNode.title; |
|
|
node['x'] = gNode.x; |
|
|
node['x'] = gNode.x; |
|
|
node['y'] = gNode.y; |
|
|
node['y'] = gNode.y; |
|
|
node['label'] = gNode.label; |
|
|
node['label'] = gNode.label; |
|
|
if (this.options.nodes.parseColor === true) { |
|
|
|
|
|
|
|
|
if (options.nodes.parseColor === true) { |
|
|
node['color'] = gNode.color; |
|
|
node['color'] = gNode.color; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
node['color'] = gNode.color !== undefined ? {background:gNode.color, border:gNode.color} : undefined; |
|
|
node['color'] = gNode.color !== undefined ? {background:gNode.color, border:gNode.color} : undefined; |
|
|
} |
|
|
} |
|
|
node['radius'] = gNode.size; |
|
|
|
|
|
node['allowedToMoveX'] = this.options.nodes.allowedToMove; |
|
|
|
|
|
node['allowedToMoveY'] = this.options.nodes.allowedToMove; |
|
|
|
|
|
|
|
|
node['size'] = gNode.size; |
|
|
|
|
|
node['fixed'] = options.nodes.fixed && gNode.x !== undefined && gNode.y !== undefined; |
|
|
nodes.push(node); |
|
|
nodes.push(node); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|