1
|
/**
|
2
|
* @constructor
|
3
|
*/
|
4
|
function GraphExporter() {
|
5
|
|
6
|
/**
|
7
|
* Exports positions of edges and vertices in graph to JSON.
|
8
|
*/
|
9
|
this.run = function() {
|
10
|
var edgesExport = app.edgeList.map(function(edge) {
|
11
|
return {
|
12
|
id: edge.id,
|
13
|
from: edge.getFrom().id,
|
14
|
to: edge.getTo().id,
|
15
|
};
|
16
|
});
|
17
|
|
18
|
var verticesExport = app.vertexList.map(function(vertex) {
|
19
|
return {
|
20
|
id: vertex.id,
|
21
|
name: vertex.name,
|
22
|
position: vertex.getPosition(),
|
23
|
isExcluded: vertex.isExcluded(),
|
24
|
};
|
25
|
});
|
26
|
|
27
|
return {
|
28
|
edges: edgesExport,
|
29
|
vertices: verticesExport,
|
30
|
};
|
31
|
};
|
32
|
|
33
|
}
|