Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Antoine Lambert
swh-graph
Commits
65c76530
Commit
65c76530
authored
4 years ago
by
Antoine Pietri
Browse files
Options
Downloads
Patches
Plain Diff
topology: InOutDegree: compute per-layer stats
parent
e960d201
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/main/java/org/softwareheritage/graph/experiments/topology/InOutDegree.java
+56
-4
56 additions, 4 deletions
...twareheritage/graph/experiments/topology/InOutDegree.java
with
56 additions
and
4 deletions
java/src/main/java/org/softwareheritage/graph/experiments/topology/InOutDegree.java
+
56
−
4
View file @
65c76530
...
...
@@ -55,6 +55,7 @@ public class InOutDegree {
}
public
static
void
run
(
final
Graph
graph
,
String
resultsDir
)
throws
IOException
{
// Per-type
var
cnt_in_dir
=
new
HashMap
<
Long
,
Long
>();
var
dir_in_dir
=
new
HashMap
<
Long
,
Long
>();
var
dir_in_rev
=
new
HashMap
<
Long
,
Long
>();
...
...
@@ -76,6 +77,18 @@ public class InOutDegree {
var
snp_out_rev
=
new
HashMap
<
Long
,
Long
>();
var
ori_out_snp
=
new
HashMap
<
Long
,
Long
>();
// Aggregated per layer
var
full_in
=
new
HashMap
<
Long
,
Long
>();
var
full_out
=
new
HashMap
<
Long
,
Long
>();
var
dircnt_in
=
new
HashMap
<
Long
,
Long
>();
var
dircnt_out
=
new
HashMap
<
Long
,
Long
>();
var
orisnp_in
=
new
HashMap
<
Long
,
Long
>();
var
orisnp_out
=
new
HashMap
<
Long
,
Long
>();
var
relrev_in
=
new
HashMap
<
Long
,
Long
>();
var
relrev_out
=
new
HashMap
<
Long
,
Long
>();
var
rev_in
=
rev_in_rev
;
// alias for single-type layer
var
rev_out
=
rev_out_rev
;
final
ProgressLogger
pl
=
new
ProgressLogger
();
pl
.
itemsName
=
"nodes"
;
pl
.
expectedUpdates
=
graph
.
numNodes
();
...
...
@@ -85,12 +98,23 @@ public class InOutDegree {
long
[]
out
;
for
(
long
i
=
graph
.
numNodes
();
i
--
!=
0
;)
{
long
d_in
=
graph
.
indegree
(
i
);
long
d_out
=
graph
.
outdegree
(
i
);
full_in
.
merge
(
d_in
,
1L
,
Long:
:
sum
);
full_out
.
merge
(
d_out
,
1L
,
Long:
:
sum
);
switch
(
graph
.
getNodeType
(
i
))
{
case
CNT:
cnt_in_dir
.
merge
(
graph
.
indegree
(
i
),
1L
,
Long:
:
sum
);
cnt_in_dir
.
merge
(
d_in
,
1L
,
Long:
:
sum
);
cnt_in_dir
.
merge
(
d_in
,
1L
,
Long:
:
sum
);
dircnt_in
.
merge
(
d_in
,
1L
,
Long:
:
sum
);
dircnt_out
.
merge
(
0L
,
1L
,
Long:
:
sum
);
case
DIR:
in
=
indegreeTypes
(
graph
,
i
);
out
=
outdegreeTypes
(
graph
,
i
);
dir_in_all
.
merge
(
in
[
TYPE_ALL
],
1L
,
Long:
:
sum
);
dir_out_all
.
merge
(
out
[
TYPE_ALL
],
1L
,
Long:
:
sum
);
dir_in_dir
.
merge
(
in
[
TYPE_DIR
],
1L
,
Long:
:
sum
);
...
...
@@ -98,25 +122,42 @@ public class InOutDegree {
dir_out_cnt
.
merge
(
out
[
TYPE_CNT
],
1L
,
Long:
:
sum
);
dir_out_dir
.
merge
(
out
[
TYPE_DIR
],
1L
,
Long:
:
sum
);
dir_out_rev
.
merge
(
out
[
TYPE_REV
],
1L
,
Long:
:
sum
);
dircnt_in
.
merge
(
in
[
TYPE_DIR
]
+
in
[
TYPE_CNT
],
1L
,
Long:
:
sum
);
dircnt_out
.
merge
(
out
[
TYPE_DIR
]
+
out
[
TYPE_CNT
],
1L
,
Long:
:
sum
);
case
REV:
in
=
indegreeTypes
(
graph
,
i
);
out
=
outdegreeTypes
(
graph
,
i
);
rev_in_all
.
merge
(
in
[
TYPE_ALL
],
1L
,
Long:
:
sum
);
rev_in_dir
.
merge
(
in
[
TYPE_DIR
],
1L
,
Long:
:
sum
);
rev_in_rev
.
merge
(
in
[
TYPE_REV
],
1L
,
Long:
:
sum
);
rev_in_rel
.
merge
(
in
[
TYPE_REL
],
1L
,
Long:
:
sum
);
rev_in_snp
.
merge
(
in
[
TYPE_SNP
],
1L
,
Long:
:
sum
);
rev_out_rev
.
merge
(
out
[
TYPE_REV
],
1L
,
Long:
:
sum
);
relrev_in
.
merge
(
in
[
TYPE_REL
]
+
in
[
TYPE_REV
],
1L
,
Long:
:
sum
);
relrev_out
.
merge
(
out
[
TYPE_REL
]
+
out
[
TYPE_REV
],
1L
,
Long:
:
sum
);
case
REL:
rel_in_snp
.
merge
(
graph
.
indegree
(
i
),
1L
,
Long:
:
sum
);
rel_in_snp
.
merge
(
d_in
,
1L
,
Long:
:
sum
);
relrev_in
.
merge
(
0L
,
1L
,
Long:
:
sum
);
relrev_out
.
merge
(
d_out
,
1L
,
Long:
:
sum
);
case
SNP:
out
=
outdegreeTypes
(
graph
,
i
);
snp_in_ori
.
merge
(
graph
.
indegree
(
i
),
1L
,
Long:
:
sum
);
snp_in_ori
.
merge
(
d_in
,
1L
,
Long:
:
sum
);
snp_out_all
.
merge
(
out
[
TYPE_ALL
],
1L
,
Long:
:
sum
);
snp_out_rel
.
merge
(
out
[
TYPE_REL
],
1L
,
Long:
:
sum
);
snp_out_rev
.
merge
(
out
[
TYPE_REV
],
1L
,
Long:
:
sum
);
orisnp_in
.
merge
(
d_in
,
1L
,
Long:
:
sum
);
orisnp_out
.
merge
(
out
[
TYPE_REL
]
+
out
[
TYPE_REV
],
1L
,
Long:
:
sum
);
case
ORI:
ori_out_snp
.
merge
(
graph
.
outdegree
(
i
),
1L
,
Long:
:
sum
);
ori_out_snp
.
merge
(
d_out
,
1L
,
Long:
:
sum
);
orisnp_in
.
merge
(
0L
,
1L
,
Long:
:
sum
);
orisnp_out
.
merge
(
d_out
,
1L
,
Long:
:
sum
);
}
pl
.
update
();
...
...
@@ -144,6 +185,17 @@ public class InOutDegree {
writeDistribution
(
snp_out_rel
,
resultsDir
+
"/snp_out_rel.txt"
);
writeDistribution
(
snp_out_rev
,
resultsDir
+
"/snp_out_rev.txt"
);
writeDistribution
(
ori_out_snp
,
resultsDir
+
"/ori_out_snp.txt"
);
writeDistribution
(
full_in
,
resultsDir
+
"/full_in.txt"
);
writeDistribution
(
full_out
,
resultsDir
+
"/full_out.txt"
);
writeDistribution
(
dircnt_in
,
resultsDir
+
"/dir+cnt_in.txt"
);
writeDistribution
(
dircnt_out
,
resultsDir
+
"/dir+cnt_out.txt"
);
writeDistribution
(
relrev_in
,
resultsDir
+
"/rel+rev_in.txt"
);
writeDistribution
(
relrev_out
,
resultsDir
+
"/rel+rev_out.txt"
);
writeDistribution
(
orisnp_in
,
resultsDir
+
"/ori+snp_in.txt"
);
writeDistribution
(
orisnp_out
,
resultsDir
+
"/ori+snp_out.txt"
);
writeDistribution
(
rev_in
,
resultsDir
+
"/rev_in.txt"
);
writeDistribution
(
rev_out
,
resultsDir
+
"/rev_out.txt"
);
}
static
public
void
main
(
final
String
[]
arg
)
...
...
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