Differential D6953 Diff 25200 java/src/main/java/org/softwareheritage/graph/experiments/topology/AveragePaths.java
Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/experiments/topology/AveragePaths.java
Show All 11 Lines | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileWriter; | import java.io.FileWriter; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
import java.util.*; | import java.util.*; | ||||
import java.util.concurrent.*; | import java.util.concurrent.*; | ||||
public class AveragePaths { | public class AveragePaths { | ||||
private final Graph graph; | private final SwhBidirectionalGraph graph; | ||||
private final Subgraph subgraph; | private final Subgraph subgraph; | ||||
private final ConcurrentHashMap<Long, Long> result; | private final ConcurrentHashMap<Long, Long> result; | ||||
private final String outdir; | private final String outdir; | ||||
public AveragePaths(String graphBasename, String allowedNodes, String outdir) throws IOException { | public AveragePaths(String graphBasename, String allowedNodes, String outdir) throws IOException { | ||||
System.err.println("Loading graph " + graphBasename + " ..."); | System.err.println("Loading graph " + graphBasename + " ..."); | ||||
this.graph = Graph.loadMapped(graphBasename); | this.graph = SwhBidirectionalGraph.loadMapped(graphBasename); | ||||
this.subgraph = new Subgraph(this.graph, new AllowedNodes(allowedNodes)); | this.subgraph = new Subgraph(this.graph, new AllowedNodes(allowedNodes)); | ||||
this.outdir = outdir; | this.outdir = outdir; | ||||
System.err.println("Graph loaded."); | System.err.println("SwhBidirectionalGraph loaded."); | ||||
result = new ConcurrentHashMap<>(); | result = new ConcurrentHashMap<>(); | ||||
} | } | ||||
private static JSAPResult parse_args(String[] args) { | private static JSAPResult parse_args(String[] args) { | ||||
JSAPResult config = null; | JSAPResult config = null; | ||||
try { | try { | ||||
SimpleJSAP jsap = new SimpleJSAP(AveragePaths.class.getName(), "", | SimpleJSAP jsap = new SimpleJSAP(AveragePaths.class.getName(), "", | ||||
Show All 20 Lines | public class AveragePaths { | ||||
private void run(int numThreads) throws InterruptedException { | private void run(int numThreads) throws InterruptedException { | ||||
final long END_OF_QUEUE = -1L; | final long END_OF_QUEUE = -1L; | ||||
ArrayBlockingQueue<Long> queue = new ArrayBlockingQueue<>(numThreads); | ArrayBlockingQueue<Long> queue = new ArrayBlockingQueue<>(numThreads); | ||||
ExecutorService service = Executors.newFixedThreadPool(numThreads + 1); | ExecutorService service = Executors.newFixedThreadPool(numThreads + 1); | ||||
service.submit(() -> { | service.submit(() -> { | ||||
try { | try { | ||||
Graph thread_graph = graph.copy(); | SwhBidirectionalGraph thread_graph = graph.copy(); | ||||
Subgraph thread_subgraph = subgraph.copy(); | Subgraph thread_subgraph = subgraph.copy(); | ||||
long[][] randomPerm = Util.identity(thread_graph.numNodes()); | long[][] randomPerm = Util.identity(thread_graph.numNodes()); | ||||
LongBigArrays.shuffle(randomPerm, new XoRoShiRo128PlusRandom()); | LongBigArrays.shuffle(randomPerm, new XoRoShiRo128PlusRandom()); | ||||
long n = thread_graph.numNodes(); | long n = thread_graph.numNodes(); | ||||
ProgressLogger pl = new ProgressLogger(); | ProgressLogger pl = new ProgressLogger(); | ||||
pl.expectedUpdates = n; | pl.expectedUpdates = n; | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |