本文整理汇总了Java中org.nodes.Graphs类的典型用法代码示例。如果您正苦于以下问题:Java Graphs类的具体用法?Java Graphs怎么用?Java Graphs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Graphs类属于org.nodes包,在下文中一共展示了Graphs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: instanceLoopTest3
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void instanceLoopTest3()
{
for(int i : series(20))
{
UGraph<String> graph = RandomGraphs.random(100, 200);
UPlainMotifExtractor<String> ex = new UPlainMotifExtractor<String>(graph, 100, 3, 4, 1);
List<Integer> degrees = Graphs.degrees(graph);
for(UGraph<String> sub : ex.subgraphs())
{
double sizeSlow = MotifModel.size(graph, sub, ex.occurrences(sub), new EdgeListModel(Prior.COMPLETE), true);
double sizeOld = MotifModel.sizeEL(graph, sub, ex.occurrences(sub), true);
double sizeNew = MotifModel.sizeEL(graph, degrees, sub, ex.occurrences(sub), true);
assertEquals(sizeOld, sizeNew, 0.000001);
assertEquals(sizeSlow, sizeNew, 0.000001);
}
}
}
示例2: instanceLoopTestTiming
import org.nodes.Graphs; //导入依赖的package包/类
public void instanceLoopTestTiming()
{
UGraph<String> graph = RandomGraphs.randomFast(100000, 2000000);
System.out.println("graph generated.");
UPlainMotifExtractor<String> ex = new UPlainMotifExtractor<String>(graph, 1000000, 3, 6, 1);
List<Integer> degrees = Graphs.degrees(graph);
for(UGraph<String> sub : ex.subgraphs())
{
System.out.println(ex.occurrences(sub).size() + " occurrences:");
double tOld, tNew;
tic();
double sizeOld = MotifModel.sizeER(graph, sub, ex.occurrences(sub), true);
tOld = toc();
tic();
double sizeNew = MotifModel.sizeERInst(graph, sub, ex.occurrences(sub), true);
tNew = toc();
System.out.println(" old: " + tOld + " seconds");
System.out.println(" new: " + tNew + " seconds");
}
}
示例3: instanceLoopTestTiming2
import org.nodes.Graphs; //导入依赖的package包/类
public void instanceLoopTestTiming2()
{
UGraph<String> graph = RandomGraphs.randomFast(10000, 100000);
System.out.println("graph generated.");
UPlainMotifExtractor<String> ex = new UPlainMotifExtractor<String>(graph, 100000, 3, 5, 1);
List<Integer> degrees = Graphs.degrees(graph);
UGraph<String> sub = ex.subgraphs().get(0);
tic();
for(int i : series(50))
MotifModel.sizeEL(graph, degrees, sub, ex.occurrences(sub), true);
System.out.println(toc() + " seconds.");
}
示例4: instanceLoopTestERU
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void instanceLoopTestERU()
{
for(int i : series(20))
{
UGraph<String> graph = RandomGraphs.random(100, 200);
UPlainMotifExtractor<String> ex = new UPlainMotifExtractor<String>(graph, 100, 3, 4, 1);
List<Integer> degrees = Graphs.degrees(graph);
for(UGraph<String> sub : ex.subgraphs())
{
double sizeSlow = MotifModel.size(graph, sub, ex.occurrences(sub), new ERSimpleModel(true), true);
double sizeOld = MotifModel.sizeER(graph, sub, ex.occurrences(sub), true);
double sizeNew = MotifModel.sizeERInst(graph, sub, ex.occurrences(sub), true);
System.out.println(sizeSlow + " " + sizeOld + " " + sizeNew);
assertEquals(sizeOld, sizeNew, 0.000001);
assertEquals(sizeSlow, sizeNew, 0.000001);
}
}
}
示例5: testCount4
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void testCount4()
{
UGraph<String> graph = Graphs.ladder(3, "");
System.out.println(graph);
Orca orca = new Orca(graph, false);
for(int node : series(graph.size()))
{
for(int orbit : series(orca.numOrbits()))
{
System.out.println("node " + node + ", orbit " + orbit + ":\t" + orca.orbit(node, orbit));
}
System.out.println();
}
}
示例6: print
import org.nodes.Graphs; //导入依赖的package包/类
/**
* Mapping from binary strings to canonical graphs
*/
// @Test
public void print()
{
for(int n : series(2, 6))
{
final int m = (n*n-n)/2;
Set<Graph<String>> seen = new HashSet<Graph<String>>();
for(BitString bits : BitString.all(m))
{
UGraph<String> g = Graphs.fromBits(bits, "");
if(Graphs.connected(g) && ! seen.contains(Nauty.canonize(g)))
{
System.out.println(bits + "\t" + g);
seen.add(Nauty.canonize(g));
}
}
}
}
示例7: testCompare2
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void testCompare2()
{
UGraph<String> graph = RandomGraphs.randomFast(20, 190);
tic();
Orca orca = new Orca(graph, true);
System.out.println("Orca finished, " + toc() + " seconds.");
tic();
FrequencyModel<Graph<String>> fanmod = new FrequencyModel<Graph<String>>();
for(Set<Integer> ind : new AllSubgraphs(graph, 5))
fanmod.add(c(Subgraph.uSubgraphIndices(graph, ind)));
System.out.println("Fanmod finished, " + toc() + " seconds.");
for(UGraph<String> sub : Graphs.allIsoConnected(5, "x"))
{
sub = c(sub);
assertEquals((int)fanmod.frequency(sub), orca.count(sub, true));
}
}
示例8: testSearch
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void testSearch()
{
UGraph<String> graph = Graphs.blank(graph(), "x"), orderedA, orderedB;
Order order;
// * Find the canonical order for the graph
order = Nauty.order(graph, new NaturalComparator<String>());
orderedA = Graphs.reorder(graph, order);
// * re-order graph and test
graph = Graphs.reorder(graph, Order.random(graph.size()));
order = Nauty.order(graph, new NaturalComparator<String>());
orderedB = Graphs.reorder(graph, order);
assertTrue(orderedA.equals(orderedB));
assertTrue(orderedB.equals(orderedA));
}
示例9: testSearchLegs
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void testSearchLegs()
{
UGraph<String> graph = Graphs.blank(legs(), "x"), orderedA, orderedB;
Order order;
// * Find the canonical order for the graph
order = Nauty.order(graph, new NaturalComparator<String>());
orderedA = Graphs.reorder(graph, order);
// * re-order graph and test
graph = Graphs.reorder(graph, Order.random(graph.size()));
order = Nauty.order(graph, new NaturalComparator<String>());
orderedB = Graphs.reorder(graph, order);
assertTrue(orderedA.equals(orderedB));
assertTrue(orderedB.equals(orderedA));
}
示例10: testSearchDirected
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void testSearchDirected()
{
for(int i : Series.series(20))
{
DGraph<String> graph = Graphs.blank(graphDirected(), "x"), orderedA, orderedB;
Order order;
Comparator<String> c = new NaturalComparator<String>();
// * Find the canonical order for the graph
order = Nauty.order(graph, c);
orderedA = Graphs.reorder(graph, order);
// * re-order graph and test
graph = Graphs.reorder(graph, Order.random(graph.size()));
order = Nauty.order(graph, c);
orderedB = Graphs.reorder(graph, order);
assertTrue(orderedA.equals(orderedB));
assertTrue(orderedB.equals(orderedA));
}
}
示例11: testSearchDT
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void testSearchDT()
{
DTGraph<String, String> graph = graphDT(), orderedA, orderedB;
Order order;
// * Find the canonical order for the graph
order = Nauty.order(graph, new NaturalComparator<String>());
orderedA = Graphs.reorder(graph, order);
// * re-order graph and test
graph = Graphs.reorder(graph, Order.random(graph.size()));
order = Nauty.order(graph, new NaturalComparator<String>());
orderedB = Graphs.reorder(graph, order);
assertTrue(orderedA.equals(orderedB));
assertTrue(orderedB.equals(orderedA));
}
示例12: testGenerate
import org.nodes.Graphs; //导入依赖的package包/类
@Test
public void testGenerate()
{
Graph<String> graph = Graphs.star(20, "x");
Graph<String> subTarget = Graphs.line(3, "x");
subTarget = Nauty.canonize(subTarget);
SubgraphGenerator<String> gen = new SubgraphGenerator<String>(graph, 3);
// for(int i : series(100))
// {
// Graph<String> sub = Subgraph.subgraph(graph, gen.generate().nodes());
// sub = Nauty.canonize(sub);
//
// assertEquals(subTarget, sub);
// }
}
示例13: testBetaD
import org.nodes.Graphs; //导入依赖的package包/类
public void testBetaD()
{
int iterations = 20;
DGraph<String> data = Examples.physicians();
DPlainMotifExtractor<String> ex = new DPlainMotifExtractor<String>(data, 1000, 2, 7, 1);
for(DGraph<String> sub : ex.subgraphs().subList(0, N))
{
DGraph<String> subbed = MotifModel.subbedGraph(
data, ex.occurrences(sub), new ArrayList<List<Integer>>(),
new HashSet<Integer>());
subbed = Graphs.toSimpleDGraph(subbed);
List<DSequenceEstimator.D> slowDegrees =
DSequenceEstimator.sequence(subbed);
Collections.sort(slowDegrees);
List<DSequenceEstimator.D> fastDegrees =
MotifModel.subbedDegrees(data, ex.occurrences(sub), new FrequencyModel<String>());
Collections.sort(fastDegrees);
assertEquals(slowDegrees, fastDegrees);
double sizeSlow = MotifModelTest.sizeBetaCopying(data, sub, ex.occurrences(sub), true, iterations, 0.05);
double sizeFast = MotifModel.sizeBeta(data, sub, ex.occurrences(sub), true, iterations, 0.05);
assertEquals(sizeSlow, sizeFast, 50.0);
}
}
示例14: testBetaU
import org.nodes.Graphs; //导入依赖的package包/类
public void testBetaU()
{
int iterations = 250;
UGraph<String> data = RandomGraphs.random(30, 300);
UPlainMotifExtractor<String> ex = new UPlainMotifExtractor<String>(data, 1000, 2, 7, 1);
for(UGraph<String> sub : ex.subgraphs().subList(0, N))
{
UGraph<String> subbed = MotifModel.subbedGraph(
data, ex.occurrences(sub), new ArrayList<List<Integer>>(),
new HashSet<Integer>());
subbed = Graphs.toSimpleUGraph(subbed);
List<Integer> slowDegrees = Graphs.degrees(subbed);
Collections.sort(slowDegrees);
List<Integer> fastDegrees =
MotifModel.subbedDegrees(data, ex.occurrences(sub), new FrequencyModel<String>());
Collections.sort(fastDegrees);
assertEquals(slowDegrees, fastDegrees);
double sizeSlow = MotifModelTest.sizeBetaCopying(data, sub, ex.occurrences(sub), true, iterations, 0.05);
double sizeFast = MotifModel.sizeBeta(data, sub, ex.occurrences(sub), true, iterations, 0.05);
assertEquals(sizeSlow, sizeFast, 10.0);
System.out.print('.');
}
}
示例15: sumtest
import org.nodes.Graphs; //导入依赖的package包/类
public void sumtest()
{
int n = 20;
Set<BitString> set = new LinkedHashSet<BitString>();
for(double p : Series.series(0.05, 0.05, 1.0))
for(int i : Series.series(100))
set.add(BitString.random((n*n-n)/2, p));
List<Double> valuesER = new ArrayList<Double>(set.size());
List<Double> valuesEL = new ArrayList<Double>(set.size());
for(BitString bs : set)
{
UGraph<String> graph = Graphs.fromBits(bs, "");
try {
UPlainMotifExtractor<String> ex = new UPlainMotifExtractor<String>(graph, 5000, 2, 3);
for(UGraph<String> sub : ex.subgraphs())
{
valuesER.add(- MotifSearchModel.sizeER(graph, sub, ex.occurrences(sub), true));
valuesEL.add(- MotifSearchModel.sizeEL(graph, sub, ex.occurrences(sub), true));
}
} catch(Exception e)
{
System.out.println("EXCEPTION CAUGHT " + e);
}
}
double sumER = - Functions.log2Sum(valuesER);
double sumEL = - Functions.log2Sum(valuesEL);
System.out.println("sum ER: " + sumER);
System.out.println("sum EL: " + sumEL);
assertTrue(sumER > 0.0);
assertTrue(sumEL > 0.0);
}