Differential D6953 Diff 25202 java/src/main/java/org/softwareheritage/graph/experiments/forks/ListEmptyOrigins.java
Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/experiments/forks/ListEmptyOrigins.java
package org.softwareheritage.graph.experiments.forks; | package org.softwareheritage.graph.experiments.forks; | ||||
import com.martiansoftware.jsap.*; | import com.martiansoftware.jsap.*; | ||||
import it.unimi.dsi.big.webgraph.ImmutableGraph; | import it.unimi.dsi.big.webgraph.ImmutableGraph; | ||||
import it.unimi.dsi.big.webgraph.LazyLongIterator; | import it.unimi.dsi.big.webgraph.LazyLongIterator; | ||||
import org.softwareheritage.graph.Graph; | import org.softwareheritage.graph.SwhBidirectionalGraph; | ||||
import org.softwareheritage.graph.Node; | import org.softwareheritage.graph.Node; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
public class ListEmptyOrigins { | public class ListEmptyOrigins { | ||||
private Graph graph; | private SwhBidirectionalGraph graph; | ||||
private Long emptySnapshot; | private Long emptySnapshot; | ||||
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(ListEmptyOrigins.class.getName(), "", | SimpleJSAP jsap = new SimpleJSAP(ListEmptyOrigins.class.getName(), "", | ||||
new Parameter[]{new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, | new Parameter[]{new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, | ||||
'g', "graph", "Basename of the compressed graph"),}); | 'g', "graph", "Basename of the compressed graph"),}); | ||||
Show All 22 Lines | public static void main(String[] args) { | ||||
ArrayList<Long> badlist = leo.compute(leo.graph); | ArrayList<Long> badlist = leo.compute(leo.graph); | ||||
for (Long bad : badlist) { | for (Long bad : badlist) { | ||||
System.out.println(bad); | System.out.println(bad); | ||||
} | } | ||||
} | } | ||||
private void load_graph(String graphBasename) throws IOException { | private void load_graph(String graphBasename) throws IOException { | ||||
System.err.println("Loading graph " + graphBasename + " ..."); | System.err.println("Loading graph " + graphBasename + " ..."); | ||||
this.graph = Graph.loadMapped(graphBasename); | this.graph = SwhBidirectionalGraph.loadMapped(graphBasename); | ||||
System.err.println("Graph loaded."); | System.err.println("Graph loaded."); | ||||
this.emptySnapshot = null; | this.emptySnapshot = null; | ||||
} | } | ||||
private boolean nodeIsEmptySnapshot(Long node) { | private boolean nodeIsEmptySnapshot(Long node) { | ||||
System.err.println(this.graph.getNodeType(node) + " " + this.graph.outdegree(node) + " " + node); | System.err.println(this.graph.getNodeType(node) + " " + this.graph.outdegree(node) + " " + node); | ||||
if (this.emptySnapshot == null && this.graph.getNodeType(node) == Node.Type.SNP | if (this.emptySnapshot == null && this.graph.getNodeType(node) == Node.Type.SNP | ||||
&& this.graph.outdegree(node) == 0) { | && this.graph.outdegree(node) == 0) { | ||||
Show All 28 Lines |