Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
pbloem committed Nov 10, 2016
1 parent 59fbd07 commit f2ab5e0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/nl/peterbloem/motive/MotifModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ public static double sizeEL(DGraph<?> graph, List<D> degrees, DGraph<?> sub,
Global.log().info("Number of links rewritten too high (with "+occurrences.size()+" instances). Returning Double.POSTIVE_INFINITY.");
return Double.POSITIVE_INFINITY;
}

// * store the template graph (as a simple graph)
bits.add("subbed", EdgeListModel.directed(sDegrees, Prior.COMPLETE));

Expand Down Expand Up @@ -1346,7 +1346,7 @@ public static List<D> subbedDegrees(
subbedDegrees.set(occurrence.get(0), new D(0, 0));

// * convert the rewritten links to new indices, and build a
// frequencymodel
// frequencymodel
int size = 0;
for(Pair<Integer, Integer> link : rewLinks)
{
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/nl/peterbloem/motive/exec/CompareLarge.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ public void main() throws IOException

MotifModel.setMaxRW(maxRW);

Global.log().info("Graph size: " + data.size() + " nodes.");
Global.log().info("Graph size: " + data.numLinks() + " links.");

Global.log().info("Computing motif code lengths");

final List<D> degrees = graphLoop ? null : DSequenceEstimator.sequence(data);

// * Sample for motifs, and collect the results
DPlainMotifExtractor<String> ex
= new DPlainMotifExtractor<String>(
Expand Down
41 changes: 41 additions & 0 deletions src/test/java/nl/peterbloem/motive/MotifModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.junit.Test;
import org.nodes.DGraph;
import org.nodes.DiskDGraph;
import org.nodes.Graph;
import org.nodes.Graphs;
import org.nodes.Link;
Expand All @@ -46,6 +47,7 @@
import org.nodes.util.bootstrap.LogNormalCI;

import nl.peterbloem.kit.BitString;
import nl.peterbloem.kit.FileIO;
import nl.peterbloem.kit.FrequencyModel;
import nl.peterbloem.kit.Functions;
import nl.peterbloem.kit.Global;
Expand Down Expand Up @@ -835,4 +837,43 @@ public void instanceLoopTestInfinities()
}
}

@Test
public void diskBasedStressTest()
{
int n = 100;

for(int i : series(n))
{
go(new Random().nextInt(10000));
Functions.dot(i, n);
}
}

public void go(long seed)
{
Global.setSeed(seed);
DGraph<String> graph = RandomGraphs.randomDirectedFast(1000, 500000);
graph = DiskDGraph.copy(graph, new File("./tmp/"));

DPlainMotifExtractor<String> ex = new DPlainMotifExtractor<>(graph, 100, 4, 3);
List<D> degrees = DSequenceEstimator.sequence(graph);

for(DGraph<String> sub : ex.subgraphs())
{
List<List<Integer>> occ = ex.occurrences(sub);

try
{
MotifSearchModel.sizeELInst(graph, degrees, sub, occ, true, -1);
} catch(RuntimeException e)
{
Global.log().info("seed " + Global.randomSeed());
throw e;
}
}

FileIO.rDelete(new File("./tmp"));

}

}

0 comments on commit f2ab5e0

Please sign in to comment.