Page MenuHomeSoftware Heritage
Paste P741

(An Untitled Masterwork)
ActivePublic

Authored by seirl on Aug 13 2020, 12:34 AM.
public class ReadLabelledGraph {
public static void main(String[] args) throws IOException, ClassNotFoundException {
String graphPath = args[0];
ArcLabelledImmutableGraph graph = BitStreamArcLabelledImmutableGraph.loadOffline(graphPath + "-labelled");
ArcLabelledNodeIterator it = graph.nodeIterator();
while (it.hasNext()) {
long srcNode = it.nextLong();
ArcLabelledNodeIterator.LabelledArcIterator s = it.successors();
long dstNode;
while ((dstNode = s.nextLong()) >= 0) {
int label = (int) s.label().get();
int missing = (1 << s.label().fixedWidth()) - 1;
if (label == missing)
label = -1;
System.out.format(
"%d %d %d\n",
srcNode,
dstNode,
label)
);
}
}
}
}