Skip to content
Snippets Groups Projects
Commit 41c9ae92 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Missing sanity check

parent 05c61ee2
Branches
Tags
No related merge requests found
...@@ -39,14 +39,18 @@ public class NetworkParser { ...@@ -39,14 +39,18 @@ public class NetworkParser {
//Loop over edges //Loop over edges
for (CyEdge e : edges) { for (CyEdge e : edges) {
CyRow edgeEntry = net.getRow(e);
//Parse editing costs //Parse editing costs
double weight = deletionCostDefault; double weight = deletionCostDefault;
//Fetch entry and check if it exists
CyRow edgeEntry = net.getRow(e);
//Check if there is a weight column defined, else skip
if (weightColumn != null){ if (weightColumn != null){
System.out.println("Using column: "+weightColumn.getName()); //Check if the column contains an entry for the respective edge
try { //It is possible, that there are missing entries
//Find out if the weights are double or int if (edgeEntry.getAllValues().containsKey(weightColumn.getName())){
//Find out if the weights are double or integer and cast accordingly
Class<?> weightType = weightColumn.getType(); Class<?> weightType = weightColumn.getType();
if (weightType == Integer.class) { if (weightType == Integer.class) {
weight = (int)edgeEntry.get(weightColumn.getName(), weightType); weight = (int)edgeEntry.get(weightColumn.getName(), weightType);
...@@ -54,11 +58,7 @@ public class NetworkParser { ...@@ -54,11 +58,7 @@ public class NetworkParser {
else if(weightType == Double.class) { else if(weightType == Double.class) {
weight = (double)edgeEntry.get(weightColumn.getName(), weightType); weight = (double)edgeEntry.get(weightColumn.getName(), weightType);
} }
}
catch(Exception ex) {
ex.printStackTrace();
//Invalid entry (no entry)
logger.info("No valid edit costs defined for: "+edgeEntry.get("name", String.class)+", falling back to default value!");
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment