Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
update SSSP application to use more aggregators like maximum out-degree
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiugh committed Mar 7, 2011
1 parent 130697c commit facd2a5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/nl/vu/cs/amstel/examples/SSSP.java
@@ -1,10 +1,11 @@
package nl.vu.cs.amstel.examples;

import nl.vu.cs.amstel.Node;
import nl.vu.cs.amstel.graph.io.LognormGraphGenerator;
import nl.vu.cs.amstel.graph.io.Reader;
import nl.vu.cs.amstel.graph.io.WheelGraphGenerator;
import nl.vu.cs.amstel.user.IntMessage;
import nl.vu.cs.amstel.user.IntValue;
import nl.vu.cs.amstel.user.MaxIntAggregator;
import nl.vu.cs.amstel.user.MinIntAggregator;
import nl.vu.cs.amstel.user.MinIntCombiner;

Expand All @@ -31,12 +32,13 @@ public static void main(String args[]) throws Exception {
throw new Exception("Source and destination not specified");
}

Reader reader = new WheelGraphGenerator(filename);
Reader reader = new LognormGraphGenerator(filename);
Node<IntValue, IntValue, IntMessage> node =
new Node<IntValue, IntValue, IntMessage>(nodes, SSSPVertex.class,
IntValue.class, IntValue.class, IntMessage.class, reader);
node.setCombiner(MinIntCombiner.class);
node.addAggregator(new MinIntAggregator("Destination"));
node.addAggregator(new MaxIntAggregator("Max-Outdegree"));
node.run();
}
}
4 changes: 4 additions & 0 deletions src/nl/vu/cs/amstel/examples/SSSPVertex.java
Expand Up @@ -17,9 +17,13 @@ public class SSSPVertex extends Vertex<IntValue, IntValue, IntMessage> {
public static String SRC = null;
public static String DST = null;

private static IntValue outdegree = new IntValue();

@Override
public void compute(Iterable<IntMessage> messages) {
if (getSuperstep() == 0) {
outdegree.value = getOutdegree();
outputAggregate("Max-Outdegree", outdegree);
getValue().value = Integer.MAX_VALUE;
return;
} else if (getSuperstep() > SP_TH) {
Expand Down
4 changes: 4 additions & 0 deletions src/nl/vu/cs/amstel/graph/VertexState.java
Expand Up @@ -83,6 +83,10 @@ public V getValue() {
return value;
}

public int getOutdegree() {
return edges.length;
}

public String[] getOutEdges() {
return edges;
}
Expand Down
8 changes: 4 additions & 4 deletions src/nl/vu/cs/amstel/graph/io/TextFileReader.java
Expand Up @@ -26,7 +26,7 @@ public class TextFileReader implements Reader {
private long fileSize;

private MappedByteBuffer mappedMem;
private ByteArrayOutputStream buffer = new ByteArrayOutputStream();
private ByteArrayOutputStream lineBuffer = new ByteArrayOutputStream();
private long offset;
private long length;
private long bytesRead = 0;
Expand Down Expand Up @@ -102,14 +102,14 @@ public boolean hasNext() {

private String readLine() {
byte b;
buffer.reset();
lineBuffer.reset();
while ((bytesRead < length) && ((b = mappedMem.get()) != '\n')) {
buffer.write(b);
lineBuffer.write(b);
bytesRead++;
}
bytesRead++;

return buffer.toString();
return lineBuffer.toString();
}

@SuppressWarnings("unchecked")
Expand Down
4 changes: 4 additions & 0 deletions src/nl/vu/cs/amstel/user/Vertex.java
Expand Up @@ -49,6 +49,10 @@ public OutEdgeIterator<E> getOutEdgeIterator() {
return workerState.edgeIterator;
}

public int getOutdegree() {
return state.getOutdegree();
}

public void send(String toVertex, M m) {
try {
workerState.router.send(toVertex, m);
Expand Down

0 comments on commit facd2a5

Please sign in to comment.