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
cd45442e
Commit
cd45442e
authored
2 years ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
TopoSort: Use a bit array instead of a set
parent
aa021f95
No related branches found
Branches containing commit
Tags
v6.3.1
Tags containing commit
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/utils/TopoSort.java
+4
-3
4 additions, 3 deletions
.../main/java/org/softwareheritage/graph/utils/TopoSort.java
with
4 additions
and
3 deletions
java/src/main/java/org/softwareheritage/graph/utils/TopoSort.java
+
4
−
3
View file @
cd45442e
...
...
@@ -10,6 +10,7 @@ package org.softwareheritage.graph.utils;
import
com.martiansoftware.jsap.*
;
import
it.unimi.dsi.big.webgraph.LazyLongIterator
;
import
it.unimi.dsi.big.webgraph.NodeIterator
;
import
it.unimi.dsi.bits.LongArrayBitVector
;
import
org.softwareheritage.graph.*
;
import
java.io.IOException
;
...
...
@@ -77,7 +78,7 @@ public class TopoSort {
/* Prints nodes in topological order, based on a DFS. */
public
void
toposortDFS
()
{
HashSet
<
Long
>
visited
=
new
HashSet
<
Long
>(
);
LongArrayBitVector
visited
=
LongArrayBitVector
.
ofLength
(
graph
.
numNodes
()
);
Stack
<
Long
>
ready
=
new
Stack
<>();
/* First, push all leaves to the stack */
...
...
@@ -106,7 +107,7 @@ public class TopoSort {
long
printed_nodes
=
0
;
while
(!
ready
.
isEmpty
())
{
long
currentNodeId
=
ready
.
pop
();
visited
.
add
(
currentNodeId
);
visited
.
set
(
currentNodeId
);
/* Find its successors which are ready */
LazyLongIterator
successors
=
transposedGraph
.
successors
(
currentNodeId
);
...
...
@@ -116,7 +117,7 @@ public class TopoSort {
LazyLongIterator
successorAncestors
=
graph
.
successors
(
successorNodeId
);
boolean
isReady
=
true
;
for
(
long
successorAncestorNodeId
;
(
successorAncestorNodeId
=
successorAncestors
.
nextLong
())
!=
-
1
;)
{
if
(!
visited
.
contains
(
successorAncestorNodeId
))
{
if
(!
visited
.
getBoolean
(
successorAncestorNodeId
))
{
/*
* This ancestor of the successor is not yet visited, so the ancestor is not ready.
*/
...
...
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