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
086db2d8
Commit
086db2d8
authored
Jul 03, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP edgetypes: first quick working version (unoptimized)
parent
039ff7ad
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
216 additions
and
112 deletions
+216
-112
Tinaweb.js
twmain/Tinaweb.js
+106
-59
enviroment.js
twmain/enviroment.js
+68
-28
main.js
twmain/main.js
+12
-3
methods.js
twmain/methods.js
+8
-6
sigmaUtils.js
twmain/sigmaUtils.js
+22
-16
No files found.
twmain/Tinaweb.js
View file @
086db2d8
...
...
@@ -175,6 +175,7 @@ function SelectionEngine() {
var
activetypesKey
=
getActivetypesKey
()
var
activereltypes
=
TW
.
SystemState
().
activereltypes
// Dictionaries of: selection+neighbors for the new state and updateRelatedNodesPanel
...
...
@@ -182,7 +183,11 @@ function SelectionEngine() {
// detailed relations sorted by types and srcid (for state cache, deselects etc)
let
activeRelations
=
{}
activeRelations
[
activetypesKey
]
=
{}
for
(
var
k
in
activereltypes
)
{
let
activereltype
=
activereltypes
[
k
]
activeRelations
[
activereltype
]
=
{}
}
// cumulated neighbor weights no matter what srcid (for tagCloud etc)
let
sameSideNeighbors
=
{}
...
...
@@ -197,59 +202,66 @@ function SelectionEngine() {
for
(
var
i
in
ndsids
)
{
var
srcnid
=
ndsids
[
i
];
if
(
TW
.
Relations
[
activetypesKey
]
&&
TW
.
Relations
[
activetypesKey
][
srcnid
]
)
{
var
neighs
=
TW
.
Relations
[
activetypesKey
][
srcnid
]
activeRelations
[
activetypesKey
][
srcnid
]
=
{}
for
(
var
k
in
activereltypes
)
{
let
activereltype
=
activereltypes
[
k
]
if
(
neighs
)
{
for
(
var
j
in
neighs
)
{
var
tgtnid
=
neighs
[
j
]
if
(
TW
.
Relations
[
activereltype
]
&&
TW
.
Relations
[
activereltype
][
srcnid
]
)
{
var
neighs
=
TW
.
Relations
[
activereltype
][
srcnid
]
let
tgt
=
TW
.
partialGraph
.
graph
.
nodes
(
tgtnid
)
// highlight edges (except if n hidden or e dropped (<=> lock))
// POSS: use sigma's own index to avoid checking if edge dropped
if
(
tgt
&&
!
tgt
.
hidden
)
{
activeRelations
[
activereltype
][
srcnid
]
=
{}
let
eid1
=
srcnid
+
';'
+
tgtnid
let
eid2
=
tgtnid
+
';'
+
srcnid
if
(
neighs
)
{
for
(
var
j
in
neighs
)
{
var
tgtnid
=
neighs
[
j
]
if
(
(
TW
.
Edges
[
eid1
]
&&
!
TW
.
Edges
[
eid1
].
lock
)
||
(
TW
.
Edges
[
eid2
]
&&
!
TW
.
Edges
[
eid2
].
lock
)
)
{
let
tgt
=
TW
.
partialGraph
.
graph
.
nodes
(
tgtnid
)
// highlight edges (except if n hidden or e dropped (<=> lock))
// POSS: use sigma's own index to avoid checking if edge dropped
if
(
tgt
&&
!
tgt
.
hidden
)
{
let
e
1
=
TW
.
partialGraph
.
graph
.
edges
(
eid1
)
let
e
2
=
TW
.
partialGraph
.
graph
.
edges
(
eid2
)
let
e
id1
=
srcnid
+
';'
+
tgtnid
let
e
id2
=
tgtnid
+
';'
+
srcnid
// since we're there we'll also keep the neighbors info
if
(
typeof
sameSideNeighbors
[
tgtnid
]
==
'undefined'
)
{
sameSideNeighbors
[
tgtnid
]
=
0
}
if
(
(
TW
.
Edges
[
eid1
]
&&
!
TW
.
Edges
[
eid1
].
lock
)
||
(
TW
.
Edges
[
eid2
]
&&
!
TW
.
Edges
[
eid2
].
lock
)
)
{
// and the detailed info
if
(
typeof
activeRelations
[
activetypesKey
][
srcnid
][
tgtnid
]
==
'undefined'
)
{
activeRelations
[
activetypesKey
][
srcnid
][
tgtnid
]
=
0
}
let
e1
=
TW
.
partialGraph
.
graph
.
edges
(
eid1
)
let
e2
=
TW
.
partialGraph
.
graph
.
edges
(
eid2
)
// **make the edge active**
if
(
e1
&&
!
e1
.
hidden
)
{
e1
.
customAttrs
.
activeEdge
=
1
;
sameSideNeighbors
[
tgtnid
]
+=
e1
.
weight
||
1
activeRelations
[
activetypesKey
][
srcnid
][
tgtnid
]
+=
e1
.
weight
||
1
}
if
(
e2
&&
!
e2
.
hidden
)
{
e2
.
customAttrs
.
activeEdge
=
1
;
sameSideNeighbors
[
tgtnid
]
+=
e2
.
weight
||
1
activeRelations
[
activetypesKey
][
srcnid
][
tgtnid
]
+=
e2
.
weight
||
1
}
// since we're there we'll also keep the neighbors info
if
(
typeof
sameSideNeighbors
[
tgtnid
]
==
'undefined'
)
{
sameSideNeighbors
[
tgtnid
]
=
0
}
// and the detailed info
if
(
typeof
activeRelations
[
activereltype
][
srcnid
][
tgtnid
]
==
'undefined'
)
{
activeRelations
[
activereltype
][
srcnid
][
tgtnid
]
=
0
}
// **make the edge active**
if
(
e1
&&
!
e1
.
hidden
)
{
e1
.
customAttrs
.
activeEdge
=
1
;
sameSideNeighbors
[
tgtnid
]
+=
e1
.
weight
||
1
activeRelations
[
activereltype
][
srcnid
][
tgtnid
]
+=
e1
.
weight
||
1
}
if
(
e2
&&
!
e2
.
hidden
)
{
e2
.
customAttrs
.
activeEdge
=
1
;
sameSideNeighbors
[
tgtnid
]
+=
e2
.
weight
||
1
activeRelations
[
activereltype
][
srcnid
][
tgtnid
]
+=
e2
.
weight
||
1
}
// we add as neighbor to color it (except if already in targeted)
if
(
!
tgt
.
customAttrs
.
active
)
tgt
.
customAttrs
.
highlight
=
1
;
// we add as neighbor to color it (except if already in targeted)
if
(
!
tgt
.
customAttrs
.
active
)
tgt
.
customAttrs
.
highlight
=
1
;
}
}
}
}
}
}
}
}
}
// we make the selected (source) node active too
let
src
=
TW
.
partialGraph
.
graph
.
nodes
(
srcnid
)
src
.
customAttrs
.
active
=
true
;
...
...
@@ -867,9 +879,9 @@ var TinaWebJS = function ( sigmacanvas ) {
// to init local, instance-related listeners (need to run at new sigma instance)
// args: @partialGraph = a sigma instance
this
.
initSigmaListeners
=
function
(
partialGraph
,
initialActivetypes
)
{
this
.
initSigmaListeners
=
function
(
partialGraph
,
initialActivetypes
,
initialActivereltypes
)
{
console
.
log
(
"initSigmaListeners TW.categories
"
,
TW
.
categori
es
)
console
.
log
(
"initSigmaListeners TW.categories
/ types array / reltypeskeys array: "
,
TW
.
categories
,
initialActivetypes
,
initialActivereltyp
es
)
var
selInst
=
this
.
selNgn
...
...
@@ -1066,18 +1078,28 @@ var TinaWebJS = function ( sigmacanvas ) {
// the indice of the first cat to be active (ex: '1')
let
activeId
=
initialActivetypes
.
indexOf
(
true
)
// args: for display: target div ,
// for context: family/type prop value,
// for values: the property to filter
NodeWeightFilter
(
`#slidercat
${
activeId
}
nodesweight`
,
TW
.
categories
[
activeId
]
);
// ex: #slidercat1edgesweight
EdgeWeightFilter
(
`#slidercat
${
activeId
}
edgesweight`
,
getActivetypesKey
(),
"weight"
);
for
(
let
activeId
in
initialActivetypes
)
{
if
(
initialActivetypes
[
activeId
])
{
// args: for display: target div ,
// for context: family/type prop value,
// for values: the property to filter
NodeWeightFilter
(
`#slidercat
${
activeId
}
nodesweight`
,
TW
.
categories
[
activeId
]
);
}
}
for
(
var
k
in
initialActivereltypes
)
{
let
reltypeKey
=
initialActivereltypes
[
k
]
// ex: #slidercat1edgesweight
EdgeWeightFilter
(
`#slidercat
${
activeId
}
edgesweight`
,
reltypeKey
,
"weight"
);
}
}
// node's label size
...
...
@@ -1161,14 +1183,39 @@ var TinaWebJS = function ( sigmacanvas ) {
// our current choice: show only the last cat
//
POSS make it a configuration settings
//
except when setting TW.conf.debug.initialShowAll
this
.
initialActivetypes
=
function
(
categories
)
{
var
firstActivetypes
=
[]
let
firstActivetypes
=
[]
for
(
var
i
=
0
;
i
<
categories
.
length
;
i
++
)
{
if
(
i
==
categories
.
length
-
1
)
firstActivetypes
.
push
(
true
)
if
(
TW
.
conf
.
debug
.
initialShowAll
||
i
==
categories
.
length
-
1
)
{
firstActivetypes
.
push
(
true
)
}
else
firstActivetypes
.
push
(
false
)
}
return
firstActivetypes
;
}
// new business logic associating some activetypes to some activerels
// (it now allows multiple "relation-families" to be added as visible edges)
this
.
inferActivereltypes
=
function
(
nodeActivetypes
)
{
let
firstActivereltypes
=
[]
// multiple nodetypes all true => all reltypes
if
(
TW
.
conf
.
debug
.
initialShowAll
||
nodeActivetypes
.
indexOf
(
false
)
==
-
1
)
{
let
combinations
=
{}
if
(
TW
.
categories
.
length
==
1
)
{
firstActivereltypes
=
[
'1'
]
}
else
if
(
TW
.
categories
.
length
==
2
)
{
firstActivereltypes
=
[
'0|1'
,
'1|0'
,
'1|1'
]
}
// POSSible: generalize if length > 1: recurse to generate all true/false combinations except the all-false one
}
// normal case: one activereltype, equal to the initialActivetype key
else
{
firstActivereltypes
=
[
nodeActivetypes
.
map
(
Number
).
join
(
"|"
)]
}
return
firstActivereltypes
;
}
};
twmain/enviroment.js
View file @
086db2d8
...
...
@@ -275,7 +275,9 @@ function changeType() {
// new state is the complement of the received state ~[X\Y]
var
t1Activetypes
=
[]
for
(
var
i
in
t0Activetypes
)
t1Activetypes
[
i
]
=
!
t0Activetypes
[
i
]
var
t1ActivetypesKey
=
t1Activetypes
.
map
(
Number
).
join
(
"|"
)
// apriori key
let
t1ActivetypesKey
=
t1Activetypes
.
map
(
Number
).
join
(
"|"
)
// "union realm" (where we'll search the real bipartite Relations)
var
bipartiteKey
=
"1|1"
...
...
@@ -288,7 +290,6 @@ function changeType() {
// so => we set here a fallback to "1|0"
if
(
t1ActivetypesKey
==
"0|0"
)
{
t1Activetypes
=
[
true
,
false
]
t1ActivetypesKey
=
"1|0"
// this case "0|0" => "1|0" won't have a unique edge realm to look at
// nodes of "1|0" will need their "1|0" neighbors
...
...
@@ -299,6 +300,12 @@ function changeType() {
// special case: "macro level opens bipartite possibilities"
if
(
!
level
)
t1Activetypes
=
[
true
,
true
];
// now that we have the future types, infer associated state representations
// let t1ActivetypesKey = t1Activetypes.map(Number).join("|")
let
t1Activereltypes
=
TW
.
instance
.
inferActivereltypes
(
t1Activetypes
)
console
.
log
(
"activetypes:"
,
t1ActivetypesKey
)
console
.
log
(
"activereltypes:"
,
t1Activereltypes
)
// list of present nodes: needed *before* clearing
// (but only needed if local and no selections)
...
...
@@ -324,12 +331,14 @@ function changeType() {
}
}
for
(
var
eid
in
TW
.
Edges
)
{
if
(
TW
.
Edges
[
eid
].
categ
==
t1ActivetypesKey
)
for
(
var
k
in
t1Activereltypes
)
{
let
reltype
=
t1Activereltypes
[
k
]
if
(
TW
.
Edges
[
eid
].
categ
==
reltype
)
add1Elem
(
eid
)
}
// NB ie we
don't
add sameside edges "1|0" or "0|1" when target
// activetypes is "1|1" (aka "both")
// NB ie we
**do**
add sameside edges "1|0" or "0|1" when target
// activetypes is "1|1" (aka "both")
, cf. inferActivereltypes
}
sourceNodes
=
sels
...
...
@@ -361,8 +370,8 @@ function changeType() {
// [ ChangeType: incremental selection ;]
// Dictionaries of: opposite-neighs of current source nodes
var
newnodeset
=
{}
var
newsels
=
{}
var
edgesToAdd
=
{}
for
(
var
i
in
sourceNodes
)
{
let
srcnid
=
sourceNodes
[
i
];
let
srctyp
=
TW
.
Nodes
[
srcnid
].
type
...
...
@@ -370,7 +379,17 @@ function changeType() {
if
(
!
mixedStart
)
{
// case where we have an single kind of Relations to consider
// ie the realm of the bipartite relations called "1|1"
neighs
=
TW
.
Relations
[
bipartiteKey
][
srcnid
]
for
(
var
k
in
t1Activereltypes
)
{
let
reltype
=
t1Activereltypes
[
k
]
if
(
TW
.
Relations
[
reltype
]
&&
TW
.
Relations
[
reltype
][
srcnid
])
neighs
=
neighs
.
concat
(
TW
.
Relations
[
reltype
][
srcnid
])
}
console
.
log
(
"=> neighs"
,
neighs
)
// neighs = TW.Relations[bipartiteKey][srcnid]
}
else
{
// case with a mixed starting point
...
...
@@ -394,10 +413,9 @@ function changeType() {
if
(
t1Activetypes
[
TW
.
catDict
[
tgttyp
]])
{
newsels
[
tgtnid
]
=
true
;
// since we're here we keep
the edges if needed
// since we're here we keep
in the new scope (nodeset) if local
if
(
!
present
.
level
)
{
edgesToAdd
[
`
${
srcnid
}
;
${
tgtnid
}
`
]
=
true
edgesToAdd
[
`
${
tgtnid
}
;
${
srcnid
}
`
]
=
true
newnodeset
[
tgtnid
]
=
true
}
}
}
...
...
@@ -419,8 +437,23 @@ function changeType() {
for
(
var
nid
in
newsels
)
{
add1Elem
(
nid
)
}
for
(
var
eid
in
edgesToAdd
)
{
add1Elem
(
eid
)
// new loop on current scope to add sels edges and intra-neighbors edges
for
(
var
srcnid
in
newnodeset
)
{
for
(
var
tgtnid
in
newnodeset
)
{
let
possEids
=
[
`
${
srcnid
}
;
${
tgtnid
}
`
,
`
${
tgtnid
}
;
${
srcnid
}
`
]
for
(
var
l
in
possEids
)
{
let
eid
=
possEids
[
l
]
if
(
TW
.
Edges
[
eid
])
{
let
e
=
TW
.
Edges
[
eid
]
for
(
var
k
in
t1Activereltypes
)
{
let
reltype
=
t1Activereltypes
[
k
]
if
(
e
.
categ
==
reltype
)
add1Elem
(
eid
)
}
}
}
}
}
}
...
...
@@ -430,6 +463,7 @@ function changeType() {
TW
.
pushState
({
activetypes
:
t1Activetypes
,
activereltypes
:
t1Activereltypes
,
sels
:
newselsArr
,
// rels: added by MS2 (highlighted opposite- and same-side neighbours)
// possible: add it in an early way here and request that MS2 doesn't change state
...
...
@@ -491,6 +525,7 @@ function changeLevel() {
var
activetypes
=
present
.
activetypes
;
var
activetypesKey
=
activetypes
.
map
(
Number
).
join
(
"|"
)
var
activereltypes
=
present
.
activereltypes
TW
.
partialGraph
.
graph
.
clear
();
...
...
@@ -502,22 +537,26 @@ function changeLevel() {
for
(
var
i
in
sels
)
{
s
=
sels
[
i
];
nodesToAdd
[
s
]
=
true
;
if
(
TW
.
Relations
[
activetypesKey
])
{
neigh
=
TW
.
Relations
[
activetypesKey
][
s
]
if
(
neigh
)
{
for
(
var
j
in
neigh
)
{
t
=
neigh
[
j
]
nodesToAdd
[
t
]
=
true
;
edgesToAdd
[
s
+
";"
+
t
]
=
true
;
edgesToAdd
[
t
+
";"
+
s
]
=
true
;
if
(
!
selsChecker
[
t
]
)
voisinage
[
t
]
=
true
;
}
for
(
var
k
in
activereltypes
)
{
let
activereltype
=
activereltypes
[
k
]
console
.
log
(
"level: considering reltype "
,
activereltype
)
if
(
TW
.
Relations
[
activereltype
])
{
neigh
=
TW
.
Relations
[
activereltype
][
s
]
if
(
neigh
)
{
for
(
var
j
in
neigh
)
{
t
=
neigh
[
j
]
nodesToAdd
[
t
]
=
true
;
edgesToAdd
[
s
+
";"
+
t
]
=
true
;
edgesToAdd
[
t
+
";"
+
s
]
=
true
;
if
(
!
selsChecker
[
t
]
)
voisinage
[
t
]
=
true
;
}
}
}
else
{
// case where no edges at all (ex: scholars have no common keywords)
console
.
log
(
"no edges between these nodes"
)
}
}
else
{
// case where no edges at all (ex: scholars have no common keywords)
console
.
log
(
"no edges between these nodes"
)
}
}
...
...
@@ -536,6 +575,7 @@ function changeLevel() {
if
(
voisinage
[
i
]
!=
voisinage
[
j
]
)
{
// console.log( "\t" + voisinage[i] + " vs " + voisinage[j] )
add1Elem
(
voisinage
[
i
]
+
";"
+
voisinage
[
j
]
)
add1Elem
(
voisinage
[
j
]
+
";"
+
voisinage
[
i
]
)
}
}
}
...
...
twmain/main.js
View file @
086db2d8
...
...
@@ -24,6 +24,7 @@ TW.gmenuInfos={}; // map [graphsource => { node0/1 categories
// a system state is the summary of tina situation
TW
.
initialSystemState
=
{
activetypes
:
[],
// <== filled from TW.categories
activereltypes
:
[],
// <== same for edges
level
:
true
,
selectionNids
:
[],
// <== current selection !!
selectionRels
:
[],
// <== current highlighted neighbors
...
...
@@ -366,6 +367,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
// activetypes: the node categorie(s) that is (are) currently displayed
// ex: [true,false] = [nodes of type 0 shown ; nodes of type 1 not drawn]
var
initialActivetypes
=
TW
.
instance
.
initialActivetypes
(
TW
.
categories
)
var
initialActivereltypes
=
TW
.
instance
.
inferActivereltypes
(
initialActivetypes
)
// XML parsing from ParseCustom
var
dicts
=
start
.
makeDicts
(
TW
.
categories
);
// > parse json or gexf, dictfy
...
...
@@ -406,7 +408,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
// preparing the data (TW.Nodes and TW.Edges filtered by initial type)
// POSS: avoid this step and use the filters at rendering time!
TW
.
graphData
=
{
nodes
:
[],
edges
:
[]}
TW
.
graphData
=
sigma_utils
.
FillGraph
(
initialActivetypes
,
TW
.
catDict
,
TW
.
Nodes
,
TW
.
Edges
,
TW
.
graphData
);
TW
.
graphData
=
sigma_utils
.
FillGraph
(
initialActivetypes
,
initialActivereltypes
,
TW
.
catDict
,
TW
.
Nodes
,
TW
.
Edges
,
TW
.
graphData
);
// // ----------- TEST stock parse gexf and use nodes to replace TW's ---------
...
...
@@ -496,7 +498,10 @@ function mainStartGraph(inFormat, inData, twInstance) {
// ==================================================================
// a new state
TW
.
pushState
({
'activetypes'
:
initialActivetypes
})
TW
.
pushState
({
'activetypes'
:
initialActivetypes
,
'activereltypes'
:
initialActivereltypes
})
// NB the list of nodes and edges from TW.graphData will be changed
// by changeLevel, changeType or subset sliders => no need to keep it
...
...
@@ -510,7 +515,11 @@ function mainStartGraph(inFormat, inData, twInstance) {
// renderer position depend on viewpoint/zoom (like ~ html absolute positions of the node in the div)
// now that we have a sigma instance, let's bind our click handlers to it
TW
.
instance
.
initSigmaListeners
(
TW
.
partialGraph
,
initialActivetypes
)
TW
.
instance
.
initSigmaListeners
(
TW
.
partialGraph
,
initialActivetypes
,
// to init node sliders and .class gui elements
initialActivereltypes
// to init edge sliders
)
// [ / Poblating the Sigma-Graph ]
...
...
twmain/methods.js
View file @
086db2d8
...
...
@@ -19,9 +19,10 @@ TW.pushState = function( args ) {
newState
.
id
++
// 2) we update it with provided args
if
(
!
isUndef
(
args
.
activetypes
))
newState
.
activetypes
=
args
.
activetypes
if
(
!
isUndef
(
args
.
level
))
newState
.
level
=
args
.
level
;
if
(
!
isUndef
(
args
.
sels
))
newState
.
selectionNids
=
args
.
sels
;
if
(
!
isUndef
(
args
.
activetypes
))
newState
.
activetypes
=
args
.
activetypes
if
(
!
isUndef
(
args
.
activereltypes
))
newState
.
activereltypes
=
args
.
activereltypes
if
(
!
isUndef
(
args
.
level
))
newState
.
level
=
args
.
level
;
if
(
!
isUndef
(
args
.
sels
))
newState
.
selectionNids
=
args
.
sels
;
// neighbors (of any type) and their edges in an .selectionRels[type] slot
if
(
!
isUndef
(
args
.
rels
))
newState
.
selectionRels
=
args
.
rels
;
...
...
@@ -72,9 +73,10 @@ TW.pushState = function( args ) {
NodeWeightFilter
(
"#slidercat0nodesweight"
,
TW
.
categories
[
0
]);
NodeWeightFilter
(
"#slidercat1nodesweight"
,
TW
.
categories
[
1
]);
// only truly bipartite edges => only one GUI slider
showDisabledSlider
(
"#slidercat0edgesweight"
)
EdgeWeightFilter
(
"#slidercat1edgesweight"
,
"1|1"
,
"weight"
);
// one slider for each intra-type reltype
EdgeWeightFilter
(
"#slidercat0edgesweight"
,
"1|0"
,
"weight"
);
EdgeWeightFilter
(
"#slidercat1edgesweight"
,
"0|1"
,
"weight"
);
// NB: no slider for truly bipartite edges => 2 GUI sliders but 3 edge types
}
}
...
...
twmain/sigmaUtils.js
View file @
086db2d8
...
...
@@ -3,19 +3,25 @@
var
SigmaUtils
=
function
()
{
// input = GEXFstring
this
.
FillGraph
=
function
(
initialActivetypes
,
catDict
,
nodes
,
edges
,
graph
)
{
this
.
FillGraph
=
function
(
initialActivetypes
,
initialActivereltypes
,
catDict
,
nodes
,
edges
,
graph
)
{
console
.
log
(
"Filling the graaaaph:"
)
console
.
log
(
"FillGraph catDict"
,
catDict
)
// console.log("FillGraph nodes",nodes)
// console.log("FillGraph edges",edges)
// retrocompatibility -------------------------------- 8< -------------
if
(
!
initialActivereltypes
.
length
)
{
initialActivereltypes
=
[
initialActivetypes
.
map
(
Number
).
join
(
"|"
)]
}
// ---------------------------------------------------- 8< -------------
let
i
=
0
for
(
var
nid
in
nodes
)
{
var
n
=
nodes
[
nid
];
// console.debug('tr >>> fgr node', n)
if
(
initialActivetypes
[
catDict
[
n
.
type
]]
||
TW
.
conf
.
debug
.
initialShowAll
)
{
if
(
initialActivetypes
[
catDict
[
n
.
type
]])
{
// var node = {
// id : n.id,
// label : n.label,
...
...
@@ -43,20 +49,20 @@ var SigmaUtils = function () {
}
}
// the typestring of the activetypes is the key to stored Relations (<=> edges)
var
activetypesKey
=
initialActivetypes
.
map
(
Number
).
join
(
"|"
)
for
(
let
srcnid
in
TW
.
Relations
[
activetypesKey
])
{
for
(
var
j
in
TW
.
Relations
[
activetypesKey
][
srcnid
])
{
let
tgtnid
=
TW
.
Relations
[
activetypesKey
][
srcnid
][
j
]
let
e
=
TW
.
Edges
[
srcnid
+
";"
+
tgtnid
]
if
(
e
)
{
if
(
e
.
source
!=
e
.
target
)
{
graph
.
edges
.
push
(
e
);
}
}
}
// the typestrings in activereltypes are the key to stored Relations (<=> edges)
for
(
var
k
in
initialActivereltypes
)
{
let
reltype
=
initialActivereltypes
[
k
]
for
(
let
srcnid
in
TW
.
Relations
[
reltype
])
{
for
(
var
j
in
TW
.
Relations
[
reltype
][
srcnid
])
{
let
tgtnid
=
TW
.
Relations
[
reltype
][
srcnid
][
j
]
let
e
=
TW
.
Edges
[
srcnid
+
";"
+
tgtnid
]
if
(
e
)
{
if
(
e
.
source
!=
e
.
target
)
{
graph
.
edges
.
push
(
e
);
}
}
}
}
}
return
graph
;
}
// output = sigma graph
...
...
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