Skip to content

Commit

Permalink
Bug fix in "instance loop" implementation to deal with empty occurrences
Browse files Browse the repository at this point in the history
list.
  • Loading branch information
pbloem committed Aug 17, 2016
1 parent 0385aa5 commit 143c1ce
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/nl/peterbloem/motive/MotifModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,8 @@ public static List<Integer> subbedDegrees(
FrequencyModel<Pair<Integer, Integer>> multiEdges,
List<List<Integer>> rewiring)
{
if(occurrences.isEmpty())
return degrees;

List<Integer> subbedDegrees = new ArrayList<Integer>(degrees);

Expand Down Expand Up @@ -1281,6 +1283,8 @@ public static List<D> subbedDegrees(
FrequencyModel<Pair<Integer, Integer>> multiEdges,
List<List<Integer>> rewiring)
{
if(occurrences.isEmpty())
return degrees;

List<D> subbedDegrees = new ArrayList<D>(degrees.size());
for(D degree : degrees)
Expand Down Expand Up @@ -1395,6 +1399,9 @@ public static Pair<Integer, Integer> subbedERInstances(
FrequencyModel<Pair<Integer, Integer>> multiEdges,
List<List<Integer>> rewiring)
{
if(occurrences.isEmpty())
return p(graph.size(), graph.numLinks());

int subbedSize = graph.size() - occurrences.size() * (occurrences.get(0).size() - 1);
int subbedNumLinks = graph.numLinks() - sub.numLinks() * occurrences.size();
// - we still need to remove multiple links from subbedNumLinks
Expand Down Expand Up @@ -1467,6 +1474,9 @@ public static Pair<Integer, Integer> subbedERInstances(
FrequencyModel<Pair<Integer, Integer>> multiEdges,
List<List<Integer>> rewiring)
{
if(occurrences.isEmpty())
return p(graph.size(), graph.numLinks());

int subbedSize = graph.size() - occurrences.size() * (occurrences.get(0).size() - 1);
int subbedNumLinks = graph.numLinks() - sub.numLinks() * occurrences.size();
// - we still need to remove multiple links from subbedNumLinks
Expand Down

0 comments on commit 143c1ce

Please sign in to comment.