Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clustering-louvain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
gargantext
clustering-louvain
Commits
bc60e0a6
Commit
bc60e0a6
authored
Mar 28, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python-louvain submodule added
parent
741514c3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
1 deletion
+80
-1
.gitignore
.gitignore
+2
-1
.gitmodules
.gitmodules
+6
-0
python-louvain
python-louvain
+1
-0
python-louvain
src/Data/Graph/Clustering/python/python-louvain
+1
-0
test_community_louvain.py
src/Data/Graph/Clustering/python/test_community_louvain.py
+70
-0
No files found.
.gitignore
View file @
bc60e0a6
.DS_Store
.stack-work
.stack-work-profile
.idea
*.log
tmp/
__pycache__
.gitmodules
0 → 100644
View file @
bc60e0a6
[submodule "python-louvain"]
path = python-louvain
url = https://github.com/taynaud/python-louvain
[submodule "src/Data/Graph/Clustering/python/python-louvain"]
path = src/Data/Graph/Clustering/python/python-louvain
url = https://github.com/taynaud/python-louvain
python-louvain
@
381b7db8
Subproject commit 381b7db8196f43de98d5279746173b50fbb2bea9
python-louvain
@
381b7db8
Subproject commit 381b7db8196f43de98d5279746173b50fbb2bea9
src/Data/Graph/Clustering/python/test_community_louvain.py
0 → 100644
View file @
bc60e0a6
#!/usr/bin/env python3
import
os
import
sys
sys
.
path
.
append
(
os
.
path
.
join
(
os
.
environ
[
'PWD'
],
'python'
,
'python-louvain'
))
import
networkx
as
nx
from
community.community_louvain
import
generate_dendrogram
,
partition_at_level
,
__one_level
,
__modularity
,
best_partition
from
community.community_status
import
Status
def
communities
(
parted
):
ret
=
{}
for
n
,
c
in
parted
.
items
():
ret
.
setdefault
(
c
,
[])
ret
[
c
]
.
append
(
n
)
return
ret
simpleGraph
=
nx
.
Graph
()
simpleGraph
.
add_edges_from
([
(
1
,
2
,
{
'weight'
:
1.0
}),
(
2
,
3
,
{
'weight'
:
2.0
}),
])
dendo
=
generate_dendrogram
(
simpleGraph
)
part
=
partition_at_level
(
dendo
,
len
(
dendo
)
-
1
)
print
((
simpleGraph
.
nodes
,
simpleGraph
.
edges
))
print
(
dendo
)
print
(
part
)
status
=
Status
()
status
.
init
(
simpleGraph
,
'weight'
,
None
)
__one_level
(
simpleGraph
,
status
,
'weight'
,
1.0
)
new_mod
=
__modularity
(
status
)
print
(
new_mod
)
print
(
best_partition
(
simpleGraph
))
cuiller
=
nx
.
Graph
()
cuiller
.
add_edges_from
([
(
2
,
1
,
{
'weight'
:
1
}),
(
1
,
2
,
{
'weight'
:
1
}),
(
1
,
4
,
{
'weight'
:
1
}),
(
4
,
1
,
{
'weight'
:
1
}),
(
2
,
3
,
{
'weight'
:
1
}),
(
3
,
2
,
{
'weight'
:
1
}),
(
3
,
4
,
{
'weight'
:
1
}),
(
4
,
3
,
{
'weight'
:
1
}),
(
4
,
5
,
{
'weight'
:
1
}),
(
5
,
4
,
{
'weight'
:
1
}),
])
print
(
best_partition
(
cuiller
))
karateEdges
=
[(
1
,
2
,
1.0
),(
1
,
3
,
1.0
),(
1
,
4
,
1.0
),(
1
,
5
,
1.0
),(
1
,
6
,
1.0
),(
1
,
7
,
1.0
),(
1
,
8
,
1.0
),(
1
,
9
,
1.0
),(
1
,
11
,
1.0
),(
1
,
12
,
1.0
),(
1
,
13
,
1.0
),(
1
,
14
,
1.0
),(
1
,
18
,
1.0
),(
1
,
20
,
1.0
),(
1
,
22
,
1.0
),(
1
,
32
,
1.0
),(
2
,
3
,
1.0
),(
2
,
4
,
1.0
),(
2
,
8
,
1.0
),(
2
,
14
,
1.0
),(
2
,
18
,
1.0
),(
2
,
20
,
1.0
),(
2
,
22
,
1.0
),(
2
,
31
,
1.0
),(
3
,
4
,
1.0
),(
3
,
8
,
1.0
),(
3
,
9
,
1.0
),(
3
,
10
,
1.0
),(
3
,
14
,
1.0
),(
3
,
28
,
1.0
),(
3
,
29
,
1.0
),(
3
,
33
,
1.0
),(
4
,
8
,
1.0
),(
4
,
13
,
1.0
),(
4
,
14
,
1.0
),(
5
,
7
,
1.0
),(
5
,
11
,
1.0
),(
6
,
7
,
1.0
),(
6
,
11
,
1.0
),(
6
,
17
,
1.0
),(
7
,
17
,
1.0
),(
9
,
31
,
1.0
),(
9
,
33
,
1.0
),(
9
,
34
,
1.0
),(
10
,
34
,
1.0
),(
14
,
34
,
1.0
),(
15
,
33
,
1.0
),(
15
,
34
,
1.0
),(
16
,
33
,
1.0
),(
16
,
34
,
1.0
),(
19
,
33
,
1.0
),(
19
,
34
,
1.0
),(
20
,
34
,
1.0
),(
21
,
33
,
1.0
),(
21
,
34
,
1.0
),(
23
,
33
,
1.0
),(
23
,
34
,
1.0
),(
24
,
26
,
1.0
),(
24
,
28
,
1.0
),(
24
,
30
,
1.0
),(
24
,
33
,
1.0
),(
24
,
34
,
1.0
),(
25
,
26
,
1.0
),(
25
,
28
,
1.0
),(
25
,
32
,
1.0
),(
26
,
32
,
1.0
),(
27
,
30
,
1.0
),(
27
,
34
,
1.0
),(
28
,
34
,
1.0
),(
29
,
32
,
1.0
),(
29
,
34
,
1.0
),(
30
,
33
,
1.0
),(
30
,
34
,
1.0
),(
31
,
33
,
1.0
),(
31
,
34
,
1.0
),(
32
,
33
,
1.0
),(
32
,
34
,
1.0
),(
33
,
34
,
1.0
)]
karate
=
nx
.
Graph
()
karate
.
add_edges_from
([(
s
,
t
,
{
'weight'
:
w
})
for
(
s
,
t
,
w
)
in
karateEdges
])
karate_bp
=
best_partition
(
karate
)
print
(
karate_bp
)
print
(
communities
(
karate_bp
))
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