Skip to content

Commit

Permalink
Fixed the triangle calculation for the failing loop example (#3).
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelRoeder committed Jan 10, 2018
1 parent 95e7753 commit 9631e69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ protected double calculate() {
edges[i] = grph.getOutEdges(i);
edges[i].addAll(grph.getInEdges(i));
}
/*
* A triangle is handled by the thread which handles the node with the lowest id in that triangle.
*/
new MultiThreadProcessing(graph.getGraph().getVertices()) {
@Override
protected void run(int threadID, int sourceId) {
Expand All @@ -62,7 +65,8 @@ protected void run(int threadID, int sourceId) {
if (n_2 == sourceId) {
n_2 = grph.getDirectedSimpleEdgeTail(sourceEdges[j]);
}
if (n_2 > sourceId) {
// make sure that n_2 is larger as n_1
if (n_2 > n_1) {
count += IntSets.intersection(edges[n_1], edges[n_2]).size();
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/graph_loop.n3
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<http://example.org/class> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/class> .
<http://example.org/entity1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/class> .
<http://example.org/entity1> <http://example.org/relation1> <http://example.org/entity2> .
<http://example.org/entity2> <http://example.org/relation1> <http://example.org/entity1> .
<http://example.org/entity2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/class> .

0 comments on commit 9631e69

Please sign in to comment.