Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linkprediction_depo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jacques Fize
linkprediction_depo
Commits
e0fab819
Commit
e0fab819
authored
4 years ago
by
Fize Jacques
Browse files
Options
Downloads
Patches
Plain Diff
Debug
parent
0ccb0c49
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
evalNE_script.py
+2
-2
2 additions, 2 deletions
evalNE_script.py
generate_theoric_random_graph.py
+16
-11
16 additions, 11 deletions
generate_theoric_random_graph.py
lib/random.py
+3
-3
3 additions, 3 deletions
lib/random.py
run_eval_par.py
+1
-1
1 addition, 1 deletion
run_eval_par.py
with
22 additions
and
17 deletions
evalNE_script.py
+
2
−
2
View file @
e0fab819
...
...
@@ -59,8 +59,8 @@ methods = ['random_prediction',
"
preferential_attachment
"
,
"
resource_allocation_index
"
,
"
stochastic_block_model
"
,
"
stochastic_block_model_
edge_probs
"
,
"
s
tochastic_block_model_degree_corrected
"
"
stochastic_block_model_
degree_corrected
"
,
"
s
patial_link_prediction
"
]
# Evaluate baselines
...
...
This diff is collapsed.
Click to expand it.
generate_theoric_random_graph.py
+
16
−
11
View file @
e0fab819
...
...
@@ -17,8 +17,9 @@ parser.add_argument("output_dir")
args
=
parser
.
parse_args
()
GRAPH_SIZE
=
[
100
,
150
,
200
]
EDGE_SIZE
=
[
300
,
500
]
GRAPH_SIZE
=
[
80
,
800
]
EDGE_SIZE
=
[
2
,
3
]
OUTPUT_DIR
=
args
.
output_dir
if
not
os
.
path
.
exists
(
OUTPUT_DIR
):
raise
FileExistsError
(
"
Output directory does not exists !
"
)
...
...
@@ -28,7 +29,7 @@ parameters = {
"
stochastic_block_model_graph
"
:
{
"
nb_nodes
"
:
GRAPH_SIZE
,
"
nb_edges
"
:
EDGE_SIZE
,
"
nb_com
"
:[
2
,
5
],
"
nb_com
"
:[
2
,
5
,
8
,
16
],
"
percentage_edge_betw
"
:[
0.1
,
0.01
]
},
"
ER_graph
"
:
{
...
...
@@ -38,10 +39,11 @@ parameters = {
"
powerlaw_graph
"
:
{
# configuration_model
"
nb_nodes
"
:
GRAPH_SIZE
,
"
nb_edges
"
:
EDGE_SIZE
,
"
exponent
"
:[
2
,
3
]
"
exponent
"
:[
2
,
3
],
"
tries
"
:[
100
]
},
"
spatial_graph
"
:{
"
nb_nodes
"
:
[
100
,
150
]
,
"
nb_nodes
"
:
GRAPH_SIZE
,
"
nb_edges
"
:
EDGE_SIZE
,
"
coords
"
:[
"
random
"
,
"
country
"
],
}
...
...
@@ -63,11 +65,14 @@ for method,args in pbar:
list_of_params
=
get_params
(
parameters
[
method
])
func
=
getattr
(
ra
,
method
)
for
ix
,
params
in
enumerate
(
list_of_params
):
# try:
G
=
func
(
**
params
)
G
.
graph
.
update
(
params
)
nx
.
write_gml
(
G
,
OUTPUT_DIR
+
"
/graph_{method}_{ix}.gml
"
.
format
(
method
=
method
,
ix
=
ix
),
stringizer
=
str
)
# except Exception as e:
# print(e)
params
[
"
nb_edges
"
]
=
params
[
"
nb_edges
"
]
*
params
[
"
nb_nodes
"
]
print
(
params
)
try
:
G
=
func
(
**
params
)
G
.
graph
.
update
(
params
)
nx
.
write_gml
(
G
,
OUTPUT_DIR
+
"
/graph_{method}_{ix}.gml
"
.
format
(
method
=
method
,
ix
=
ix
),
stringizer
=
str
)
except
Exception
as
e
:
print
(
e
)
print
(
"
Can
'
t generate graphs using these parameters
"
)
This diff is collapsed.
Click to expand it.
lib/random.py
+
3
−
3
View file @
e0fab819
...
...
@@ -101,7 +101,7 @@ def _conf_model(degree_seq):
return
G
def
powerlaw_graph
(
nb_nodes
,
nb_edges
,
exponent
=
2
,
tries
=
1000
,
min_deg
=
1
):
def
powerlaw_graph
(
nb_nodes
,
nb_edges
,
exponent
=
2
,
tries
=
1000
,
min_deg
=
0
):
"""
Generate a graph with a defined number of vertices, edges, and a degree distribution that fit the power law.
Using the Molloy-Reed algorithm to
...
...
@@ -186,7 +186,7 @@ def spatial_graph(nb_nodes, nb_edges, coords="country", dist_func=lambda a, b: n
for
j
in
range
(
nb_nodes
):
if
i
==
j
and
not
self_link
:
continue
data
.
append
([
i
,
j
,
dist_func
(
coords
[
i
],
coords
[
j
])])
data
.
append
([
i
,
j
,
1
/
(
1
+
(
dist_func
(
coords
[
i
],
coords
[
j
])
**
2
))
])
df
=
pd
.
DataFrame
(
data
,
columns
=
"
src tar weight
"
.
split
()).
astype
({
"
src
"
:
int
,
"
tar
"
:
int
})
df
[
"
hash
"
]
=
df
.
apply
(
lambda
x
:
"
_
"
.
join
(
sorted
([
str
(
int
(
x
.
src
)),
str
(
int
(
x
.
tar
))])),
axis
=
1
)
df
=
df
.
drop_duplicates
(
subset
=
"
hash
"
)
...
...
@@ -259,7 +259,7 @@ def stochastic_block_model_graph(nb_nodes, nb_edges, nb_com, percentage_edge_bet
percentage_edge_within
=
1
-
percentage_edge_betw
G
=
nx
.
planted_partition_graph
(
nb_com
,
int
(
np
.
round
(
nb_nodes
/
nb_com
))
,
1
,
1
)
G
=
nx
.
planted_partition_graph
(
nb_com
,
nb_nodes
//
nb_com
,
1
,
1
)
if
verbose
:
print
(
G
.
size
())
...
...
This diff is collapsed.
Click to expand it.
run_eval_par.py
+
1
−
1
View file @
e0fab819
...
...
@@ -21,7 +21,7 @@ args = parser.parse_args()
fns
=
sorted
(
glob
.
glob
(
args
.
dataset_dir
+
"
/*.
"
+
args
.
format
))
def
run_eval
(
fn
):
command
=
"
python evalNE_script.py {0} -f {1}
-n
"
.
format
(
fn
,
args
.
format
).
split
()
command
=
"
python evalNE_script.py {0} -f {1}
"
.
format
(
fn
,
args
.
format
).
split
()
output
=
subprocess
.
run
(
command
)
if
not
output
.
returncode
==
0
:
print
(
"
Error! for the command :
"
,
"
"
.
join
(
command
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment