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