-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a problem with selection head and tail IDs of an edge. Fixes #31.
- Loading branch information
1 parent
d916200
commit abb25bc
Showing
4 changed files
with
75 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/test/java/org/aksw/simba/lemming/creation/EdgeHeadTailSelectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.aksw.simba.lemming.creation; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.aksw.simba.lemming.ColouredGraph; | ||
import org.apache.jena.rdf.model.Model; | ||
import org.apache.jena.rdf.model.ModelFactory; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import it.unimi.dsi.fastutil.ints.IntSet; | ||
|
||
/** | ||
* This test checks whether the requested head and tail IDs for edges make | ||
* sense. Related to issue #31 (https://github.com/dice-group/Lemming/issues/31). | ||
* | ||
* @author Michael Röder ([email protected]) | ||
* | ||
*/ | ||
public class EdgeHeadTailSelectionTest { | ||
|
||
private static final String GRAPH_FILE1 = "head_tail_edge_selection.n3"; | ||
|
||
@Test | ||
public void testcase1() throws IOException { | ||
Model model = ModelFactory.createDefaultModel(); | ||
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(GRAPH_FILE1);) { | ||
model.read(is, null, "N3"); | ||
} | ||
|
||
GraphCreator creator = new GraphCreator(); | ||
ColouredGraph graph = creator.processModel(model); | ||
|
||
int numberOfVertices = graph.getVertices().size(); | ||
IntSet edges; | ||
for (int v = 0; v < numberOfVertices; ++v) { | ||
edges = graph.getOutEdges(v); | ||
for (int edge : edges) { | ||
Assert.assertEquals( | ||
"Found an outgoing edge of " + v | ||
+ " that has a tail with a different ID. That shouldn't happen!", | ||
v, graph.getTailOfTheEdge(edge)); | ||
} | ||
edges = graph.getInEdges(v); | ||
for (int edge : edges) { | ||
Assert.assertEquals( | ||
"Found an incoming edge of " + v | ||
+ " that has a head with a different ID. That shouldn't happen!", | ||
v, graph.getHeadOfTheEdge(edge)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<http://example.org/entity1> <http://example.org/relation1> <http://example.org/entity2> . | ||
<http://example.org/entity1> <http://example.org/relation1> <http://example.org/entity3> . | ||
<http://example.org/entity14> <http://example.org/relation1> <http://example.org/entity2> . | ||
<http://example.org/entity10> <http://example.org/relation1> <http://example.org/entity2> . | ||
<http://example.org/entity10> <http://example.org/relation1> <http://example.org/entity3> . | ||
<http://example.org/entity10> <http://example.org/relation2> <http://example.org/entity3> . | ||
<http://example.org/entity10> <http://example.org/relation3> <http://example.org/entity2> . | ||
<http://example.org/entity1> <http://example.org/relation4> <http://example.org/entity10> . |