本文整理汇总了Java中nl.peterbloem.kit.Global.randomSeed方法的典型用法代码示例。如果您正苦于以下问题:Java Global.randomSeed方法的具体用法?Java Global.randomSeed怎么用?Java Global.randomSeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nl.peterbloem.kit.Global
的用法示例。
在下文中一共展示了Global.randomSeed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
public void main() throws IOException
{
Global.randomSeed();
loadData();
int nodes = data.size();
long links = data.numLinks();
int sig;
long t0 = System.nanoTime();
if(undirected)
sig = undirected();
else
sig = directed();
double elapsed = (System.nanoTime() - t0) / 1.0e9;
String rand = String.format("%d05", Global.random().nextInt(10000));
BufferedWriter writer = new BufferedWriter(new FileWriter(new File("output."+rand+".csv")));
writer.write(id + ", " + undirected + ", " + nodes + ", " + links + ", " + sig + ", " + sampleTime + ", " + elapsed + "\n");
writer.close();
}
示例2: testRemove
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testRemove()
{
Global.randomSeed();
UGraph<String> graph = new DiskUGraph(r());
UNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null),
d = graph.add(null),
e = graph.add(null);
b.connect(a);
c.connect(a);
d.connect(a);
e.connect(a);
assertEquals(4, graph.numLinks());
assertEquals(5, graph.size());
a.remove();
assertEquals(0, graph.numLinks());
assertEquals(4, graph.size());
}
示例3: testNumLinks2
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testNumLinks2()
{
Global.randomSeed();
DGraph<String> graph = new DiskDGraph(r());
DNode<String> a = graph.add("a");
DNode<String> b = graph.add("b");
DNode<String> c = graph.add("c");
a.connect(a);
b.connect(c);
c.connect(a);
a.connect(c);
a.connect(c);
int numLinks = 0;
for(Link<String> link : graph.links())
numLinks++;
assertEquals(5, numLinks);
assertEquals(graph.numLinks(), numLinks);
}
示例4: testLinks2
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testLinks2()
{
Global.randomSeed();
UGraph<String> graph = new DiskUGraph(r());
UNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null),
d = graph.add(null),
e = graph.add(null),
f = graph.add(null);
a.connect(b);
b.connect(c);
c.connect(a);
b.connect(e);
c.connect(e);
c.connect(d);
e.connect(d);
f.connect(d);
e.connect(f);
List<ULink<String>> links = new ArrayList<ULink<String>>((int)graph.numLinks());
for(ULink<String> link : graph.links())
links.add(link);
assertEquals(9, links.size());
System.out.println(graph.links());
}
示例5: testRead
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testRead()
{
Global.randomSeed();
UTGraph<String, String> graph = RandomGraphs.preferentialAttachment(30, 2);
UTGraph<String, String> out = Dot.readUT(graph.toString());
System.out.println(graph);
System.out.println(out);
assertEquals(graph.size(), out.size());
assertEquals(graph.numLinks(), out.numLinks());
}
示例6: testToString
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testToString()
{
Global.randomSeed();
DGraph<String> graph = new DiskDGraph(r());
DNode<String> a = graph.add("a"),
b = graph.add("b");
graph.add("c");
a.connect(b);
System.out.println(graph);
}
示例7: testRemove2
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testRemove2()
{
Global.randomSeed();
UGraph<String> graph = new DiskUGraph(r());
UNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null),
d = graph.add(null);
a.connect(b);
b.connect(c);
c.connect(d);
d.connect(a);
b.remove();
assertFalse(graph.get(0).connected(graph.get(0)));
assertFalse(graph.get(0).connected(graph.get(1)));
assertTrue (graph.get(0).connected(graph.get(2)));
assertFalse(graph.get(1).connected(graph.get(0)));
assertFalse(graph.get(1).connected(graph.get(1)));
assertTrue (graph.get(1).connected(graph.get(2)));
assertTrue (graph.get(2).connected(graph.get(0)));
assertTrue (graph.get(2).connected(graph.get(1)));
assertFalse(graph.get(2).connected(graph.get(2)));
System.out.println(graph);
}
示例8: testRemove2
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testRemove2()
{
Global.randomSeed();
DGraph<String> graph = new DiskDGraph(r());
DNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null),
d = graph.add(null);
a.connect(b);
b.connect(c);
c.connect(d);
d.connect(a);
b.remove();
assertFalse(graph.get(0).connectedTo(graph.get(0)));
assertFalse(graph.get(0).connectedTo(graph.get(1)));
assertFalse(graph.get(0).connectedTo(graph.get(2)));
assertFalse(graph.get(1).connectedTo(graph.get(0)));
assertFalse(graph.get(1).connectedTo(graph.get(1)));
assertTrue (graph.get(1).connectedTo(graph.get(2)));
assertTrue (graph.get(2).connectedTo(graph.get(0)));
assertFalse(graph.get(2).connectedTo(graph.get(1)));
assertFalse(graph.get(2).connectedTo(graph.get(2)));
System.out.println(graph);
}
示例9: testConnected
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testConnected()
{
Global.randomSeed();
DGraph<String> graph = new DiskDGraph(r());
DNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null);
a.connect(b);
a.connect(c);
assertTrue(a.connected(b));
assertTrue(a.connectedTo(b));
assertFalse(a.connected(a));
assertFalse(a.connectedTo(a));
assertTrue(b.connected(a));
assertFalse(b.connectedTo(a));
assertTrue(a.connected(c));
assertTrue(a.connectedTo(c));
assertTrue(c.connected(a));
assertFalse(c.connectedTo(a));
assertFalse(b.connected(c));
assertFalse(b.connectedTo(c));
assertFalse(c.connected(b));
assertFalse(c.connectedTo(b));
}
示例10: testRandomSelfLoops
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testRandomSelfLoops() {
Global.randomSeed();
UTGraph<String, String> graph = RandomGraphs.random(30, 16);
assertFalse(Graphs.hasSelfLoops(graph));
System.out.println(graph);
System.out.println(Graphs.shuffle(graph));
}
示例11: testLinks2
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testLinks2()
{
Global.randomSeed();
DGraph<String> graph = new DiskDGraph(r());
DNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null),
d = graph.add(null),
e = graph.add(null),
f = graph.add(null);
a.connect(b);
b.connect(c);
c.connect(a);
b.connect(e);
c.connect(e);
c.connect(d);
e.connect(d);
f.connect(d);
e.connect(f);
List<DLink<String>> links = new ArrayList<DLink<String>>((int)graph.numLinks());
for(DLink<String> link : graph.links())
links.add(link);
assertEquals(9, links.size());
System.out.println(graph.links());
}
示例12: testEquals
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testEquals()
{
Global.randomSeed();
DGraph<String> g1 = new DiskDGraph(r());
g1.add("a");
g1.add("b");
g1.add("c");
g1.node("a").connect(g1.node("b"));
g1.node("b").connect(g1.node("c"));
DGraph<String> g2 = new DiskDGraph(r());
g2.add("a");
g2.add("b");
g2.add("c");
g2.node("a").connect(g2.node("b"));
g2.node("b").connect(g2.node("c"));
assertTrue(g1.equals(g2));
g2.node("a").connect(g2.node("c"));
assertFalse(g1.equals(g2));
}
示例13: testImportBig
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
public void testImportBig()
throws IOException
{
Global.randomSeed();
DGraph<String> graph = DiskDGraph.fromFile(new File("/Users/Peter/Documents/datasets/graphs/p2p/p2p.txt"), DIR);
System.out.println(graph.size());
System.out.println(graph.numLinks());
}
示例14: testImport
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
/**
*
*
* @throws IOException
*/
@Test
public void testImport()
throws IOException
{
Global.randomSeed();
FileIO.copy("graphs/p2p/p2p.txt", DIR);
DGraph<String> diskGraph = DiskDGraph.fromFile(new File(DIR, "p2p.txt"), DIR);
assertEquals(diskGraph.size(), new ArrayList<DNode<String>>(diskGraph.nodes()).size());
List<DLink<String>> links = new ArrayList<DLink<String>>((int)diskGraph.numLinks());
for(DLink<String> link : diskGraph.links())
links.add(link);
assertEquals(diskGraph.numLinks(), links.size());
DGraph<String> memGraph = Data.edgeListDirectedUnlabeled(new File(DIR, "p2p.txt"), true);
// for(int i : series(memGraph.size()))
// {
// String a = diskGraph.get(i).out() + " " + diskGraph.get(i).in();
//
// String b = memGraph.get(i).out() + " " + memGraph.get(i).in();
//
// if(! a.equals(b))
// {
// System.out.println("d " + a);
// System.out.println("m " + b);
// }
// }
assertEquals(memGraph, diskGraph);
}
示例15: testNodeLinks
import nl.peterbloem.kit.Global; //导入方法依赖的package包/类
@Test
public void testNodeLinks()
{
Global.randomSeed();
DGraph<String> graph = Examples.physicians();
graph = DiskDGraph.copy(graph, r());
for(Node<String> node : graph.nodes())
{
Collection<? extends Node<String>> nbs = node.neighbors();
for(Node<String> neighbor : nbs)
assertTrue(node.links(neighbor).size() > 0);
}
}