Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
74842dd1
Commit
74842dd1
authored
Jan 04, 2016
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comments for fa2.js
parent
296c2e8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
65 deletions
+72
-65
asyncFA2.js
tinawebJS/asyncFA2.js
+72
-65
No files found.
tinawebJS/asyncFA2.js
View file @
74842dd1
//
Mathieu Jacomy @ Sciences Po Médialab & WebAtla
s
//
Original version made by: Mathieu Jacomy @ http://github.com/jacomyal/sigma.js/blob/deprecated-v0.1/plugins/sigma.forceatlas2.j
s
// This is a Modified version made by Samuel Castillo.
var
ForceAtlas2
=
function
(
graph
)
{
var
ForceAtlas2
=
function
(
graph
)
{
var
self
=
this
;
var
self
=
this
;
this
.
graph
=
graph
;
this
.
graph
=
graph
;
...
@@ -830,8 +830,6 @@ var ForceAtlas2 = function(graph) {
...
@@ -830,8 +830,6 @@ var ForceAtlas2 = function(graph) {
};
};
};
};
var
updateMassAndGeometry
=
function
()
{
var
updateMassAndGeometry
=
function
()
{
if
(
this
.
nodes
.
length
>
1
)
{
if
(
this
.
nodes
.
length
>
1
)
{
// Compute Mass
// Compute Mass
...
@@ -883,7 +881,6 @@ var Region = function(nodes, depth) {
...
@@ -883,7 +881,6 @@ var Region = function(nodes, depth) {
this
.
updateMassAndGeometry
();
this
.
updateMassAndGeometry
();
}
}
var
buildSubRegions
=
function
()
{
var
buildSubRegions
=
function
()
{
if
(
this
.
nodes
.
length
>
1
)
{
if
(
this
.
nodes
.
length
>
1
)
{
var
leftNodes
=
[];
var
leftNodes
=
[];
...
@@ -957,64 +954,74 @@ var applyForce = function(n, Force, theta) {
...
@@ -957,64 +954,74 @@ var applyForce = function(n, Force, theta) {
}
}
};
};
var
startForceAtlas2
=
function
(
graph
,
limit_it
)
{
// pr("inside FA2")
//// if(!this.forceatlas2) {
// pr(graph);
// pr(graph.nodes[0].x)
// pr(graph.nodes[0].y)
// pr("--------")
// nodes = graph.nodes;
// for(var n in nodes) {
// if(!nodes[n].hidden)
// nodes[n].degree = 0;
// }
// edges = graph.edges;
// for(var e in edges) {
// if(!edges[e].hidden) {
// }
// }
forceatlas2
=
new
ForceAtlas2
(
graph
);
forceatlas2
.
setAutoSettings
();
forceatlas2
.
init
();
count
=
0
;
flag
=
false
;
while
(
true
){
for
(
var
jt
=
0
;
jt
<=
5
;
jt
++
){
ret
=
forceatlas2
.
onebucle
();
if
(
ret
==
"fini"
)
{
flag
=
true
;
break
;
}
}
count
++
;
if
(
flag
||
count
>
limit_it
)
break
;
}
// pr(forceatlas2.graph.nodes[0].x)
// pr(forceatlas2.graph.nodes[0].y)
// console.log("\titerations: "+count)
result
=
{
"nodes"
:
forceatlas2
.
graph
.
nodes
,
"it"
:
count
}
return
result
;
};
self
.
addEventListener
(
"message"
,
function
(
e
)
{
var
graph
=
{
// [ NEW STUFF FOR WORKERS ]
"nodes"
:
e
.
data
.
nodes
,
"edges"
:
e
.
data
.
edges
// 01. Return the values to MainContext when spatialization is finished
}
var
startForceAtlas2
=
function
(
graph
,
limit_it
)
{
var
limit_it
=
e
.
data
.
it
;
// pr("inside FA2")
result
=
startForceAtlas2
(
graph
,
limit_it
)
//// if(!this.forceatlas2) {
postMessage
({
// pr(graph);
"nodes"
:
result
.
nodes
,
// pr(graph.nodes[0].x)
"it"
:
result
.
it
// pr(graph.nodes[0].y)
});
// pr("--------")
},
false
);
// nodes = graph.nodes;
\ No newline at end of file
// for(var n in nodes) {
// if(!nodes[n].hidden)
// nodes[n].degree = 0;
// }
// edges = graph.edges;
// for(var e in edges) {
// if(!edges[e].hidden) {
// }
// }
forceatlas2
=
new
ForceAtlas2
(
graph
);
forceatlas2
.
setAutoSettings
();
forceatlas2
.
init
();
count
=
0
;
flag
=
false
;
while
(
true
){
for
(
var
jt
=
0
;
jt
<=
5
;
jt
++
){
ret
=
forceatlas2
.
onebucle
();
if
(
ret
==
"fini"
)
{
flag
=
true
;
break
;
}
}
count
++
;
if
(
flag
||
count
>
limit_it
)
break
;
}
// pr(forceatlas2.graph.nodes[0].x)
// pr(forceatlas2.graph.nodes[0].y)
// console.log("\titerations: "+count)
result
=
{
"nodes"
:
forceatlas2
.
graph
.
nodes
,
"it"
:
count
}
return
result
;
};
// 02. This receives the Input from MainContext. This will execute startForceAtlas2() and will "post" the returned values in MainContext.
self
.
addEventListener
(
"message"
,
function
(
e
)
{
var
graph
=
{
// Input: nodes and edges.
"nodes"
:
e
.
data
.
nodes
,
"edges"
:
e
.
data
.
edges
}
var
limit_it
=
e
.
data
.
it
;
// Input: nb of iterations max.
result
=
startForceAtlas2
(
graph
,
limit_it
)
// executing Jacomy's Algo.
postMessage
({
// "posting" the results in MainContext.
"nodes"
:
result
.
nodes
,
"it"
:
result
.
it
});
},
false
);
// [ / NEW STUFF FOR WORKERS ]
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment