Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-graph
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
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
Nicolas Dandrimont
swh-graph
Commits
2de4f2f4
Commit
2de4f2f4
authored
4 years ago
by
Antoine Pietri
Browse files
Options
Downloads
Patches
Plain Diff
wip immutable graph bfs
parent
15927ec5
Branches
immutable_graph
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/benchmark/BFS.java
+19
-6
19 additions, 6 deletions
...c/main/java/org/softwareheritage/graph/benchmark/BFS.java
with
19 additions
and
6 deletions
java/src/main/java/org/softwareheritage/graph/benchmark/BFS.java
+
19
−
6
View file @
2de4f2f4
...
...
@@ -3,7 +3,9 @@ package org.softwareheritage.graph.benchmark;
import
com.google.common.primitives.Longs
;
import
it.unimi.dsi.big.webgraph.ImmutableGraph
;
import
it.unimi.dsi.big.webgraph.LazyLongIterator
;
import
it.unimi.dsi.big.webgraph.NodeIterator
;
import
it.unimi.dsi.big.webgraph.typed.BVImmutableTypedGraph
;
import
it.unimi.dsi.big.webgraph.typed.TypedGraph
;
import
it.unimi.dsi.bits.LongArrayBitVector
;
import
it.unimi.dsi.io.ByteDiskQueue
;
import
org.slf4j.Logger
;
...
...
@@ -42,7 +44,11 @@ public class BFS {
final
byte
[]
byteBuf
=
new
byte
[
Long
.
BYTES
];
// WARNING: no 64-bit version of this data-structure, but it can support
// indices up to 2^37
final
LongArrayBitVector
visited
=
LongArrayBitVector
.
ofLength
(
n
);
long
nbTypes
=
graph
.
typeGraph
().
numNodes
();
final
LongArrayBitVector
[]
visited
=
new
LongArrayBitVector
[(
int
)
nbTypes
];
for
(
int
i
=
0
;
i
<
nbTypes
;
++
i
)
visited
[
i
]
=
LongArrayBitVector
.
ofLength
(
n
);
final
ProgressLogger
pl
=
new
ProgressLogger
(
LOGGER
);
pl
.
expectedUpdates
=
n
;
pl
.
itemsName
=
"nodes"
;
...
...
@@ -50,10 +56,12 @@ public class BFS {
long
pos
=
0
;
for
(
long
i
=
0
;
i
<
n
;
i
++)
{
if
(
visited
.
getBoolean
(
i
))
continue
;
final
NodeIterator
nodeIterator
=
graph
.
nodeIterator
();
while
(
nodeIterator
.
hasNext
())
{
long
i
=
nodeIterator
.
nextLong
();
if
(
visited
[
TypedGraph
.
type
(
i
)].
getBoolean
(
i
))
continue
;
queue
.
enqueue
(
Longs
.
toByteArray
(
i
));
visited
.
set
(
i
);
visited
[
TypedGraph
.
type
(
i
)]
.
set
(
i
);
while
(!
queue
.
isEmpty
())
{
queue
.
dequeue
(
byteBuf
);
...
...
@@ -61,9 +69,13 @@ public class BFS {
final
LazyLongIterator
iterator
=
graph
.
successors
(
currentNode
);
long
succ
;
System
.
err
.
println
(
"lol2"
);
while
((
succ
=
iterator
.
nextLong
())
!=
-
1
)
{
if
(!
visited
.
getBoolean
(
succ
))
{
visited
.
set
(
succ
);
System
.
err
.
println
(
"lol3"
);
if
(!
visited
[
TypedGraph
.
type
(
succ
)].
getBoolean
(
succ
))
{
System
.
err
.
println
(
"lol4"
);
visited
[
TypedGraph
.
type
(
succ
)].
set
(
succ
);
queue
.
enqueue
(
Longs
.
toByteArray
(
succ
));
}
}
...
...
@@ -112,6 +124,7 @@ public class BFS {
double
totalTime
;
logger
.
start
(
"Loading graph..."
);
BFS
bfs
=
new
BFS
();
try
{
bfs
.
load_graph
(
graphPath
);
...
...
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