Skip to content

Commit

Permalink
Small bug were the edges were being created
Browse files Browse the repository at this point in the history
  • Loading branch information
fotisp committed Jan 3, 2012
1 parent 2529792 commit 8c2aa37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package eu.alertproject.iccs.graph.kde.api;

import edu.uci.ics.jung.algorithms.filters.EdgePredicateFilter;
import edu.uci.ics.jung.algorithms.filters.VertexPredicateFilter;
import edu.uci.ics.jung.algorithms.scoring.BetweennessCentrality;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.UndirectedGraph;
import edu.uci.ics.jung.graph.UndirectedSparseGraph;
import org.apache.commons.collections15.Predicate;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections15.TransformerUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Expand All @@ -15,9 +12,7 @@
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -45,7 +40,6 @@ public Graph<Integer, String> create(File inputFile,File outputFile){
try {
it = FileUtils.lineIterator(inputFile, "UTF-8");


Integer previousFile = null;
Integer previousAuthor = null;

Expand All @@ -58,33 +52,27 @@ public Graph<Integer, String> create(File inputFile,File outputFile){

String[] split = next.split(",");

Integer fileId = Integer.valueOf(split[0]);
Integer authorId = Integer.valueOf(split[1]);

if (previousFile != null && previousFile.equals(fileId)) {

if(previousAuthor != null){

String edge = previousFile + "_" + previousAuthor + "_" + authorId;
logger.trace("Graph<Integer,String> create() {} ",next);
String edge = DigestUtils.md5Hex(String.valueOf(previousAuthor * authorId*37));

//already added
if (!graph.containsEdge(edge)) {
logger.trace("Graph<Integer,String> create(split) Adding edge {} ",edge);
graph.addEdge(edge, previousAuthor, authorId);
weights.put(edge, 1);
} else {
weights.put(edge, weights.get(edge).intValue() + 1);
}

previousAuthor = authorId;

} else {

previousAuthor = authorId;
previousFile = fileId;
}
previousAuthor = authorId;

max--;


}


Expand Down
1 change: 1 addition & 0 deletions eu.alert-project.iccs.graph/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
<version>${commons-io.commons-io.version}</version>
</dependency>


<!-- Inhouse -->
<dependency>
<groupId>com.existanze.libraries</groupId>
Expand Down

0 comments on commit 8c2aa37

Please sign in to comment.