Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
48adeb4a
Commit
48adeb4a
authored
Nov 21, 2014
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEATURE] cleaning the graph.
parent
f4378a38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
views.py
gargantext_web/views.py
+7
-1
No files found.
gargantext_web/views.py
View file @
48adeb4a
...
...
@@ -437,13 +437,14 @@ def json_node_link(request):
for
cooccurrence
in
NodeNgramNgram
.
objects
.
filter
(
node
=
cooc
):
matrix
[
cooccurrence
.
ngramx
.
terms
][
cooccurrence
.
ngramy
.
terms
]
=
cooccurrence
.
score
matrix
[
cooccurrence
.
ngramy
.
terms
][
cooccurrence
.
ngramx
.
terms
]
=
cooccurrence
.
score
import
pandas
as
pd
from
copy
import
copy
import
numpy
as
np
import
networkx
as
nx
from
gargantext_web.api
import
JsonHttpResponse
#from analysis.louvain import *
df
=
pd
.
DataFrame
(
matrix
)
.
T
.
fillna
(
0
)
x
=
copy
(
df
.
values
)
x
=
x
/
x
.
sum
(
axis
=
1
)
...
...
@@ -451,6 +452,11 @@ def json_node_link(request):
matrix_filtered
=
np
.
where
(
x
>
.2
,
1
,
0
)
G
=
nx
.
from_numpy_matrix
(
matrix_filtered
)
G
=
nx
.
relabel_nodes
(
G
,
dict
(
enumerate
(
df
.
columns
)))
outdeg
=
G
.
degree
()
to_remove
=
[
n
for
n
in
outdeg
if
outdeg
[
n
]
<=
1
]
G
.
remove_nodes_from
(
to_remove
)
from
networkx.readwrite
import
json_graph
data
=
json_graph
.
node_link_data
(
G
)
return
JsonHttpResponse
(
data
)
...
...
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