-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomWalkTest.java
62 lines (50 loc) · 1.24 KB
/
RandomWalkTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package me.mikusugar.node2vec;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
/**
* @author mikusugar
* @version 1.0, 2023/8/3 16:02
* @description
*/
public class RandomWalkTest
{
@Test
public void testRandomWalk()
{
final Graph graph = creatGraph();
RandomWalk randomWalk = new RandomWalk(1, 1, 5, 10, graph);
final List<int[]> res = randomWalk.simulateWalks();
for (int[] walks : res)
{
System.out.println(Arrays.toString(walks));
}
}
private static Graph creatGraph()
{
Graph graph = new Graph();
for (int i = 1; i <= 8; i++)
{
graph.addNode(i);
}
graph.addEdge(1, 2);
graph.addEdge(1, 3);
graph.addEdge(1, 4);
graph.addEdge(1, 5);
graph.addEdge(2, 1);
graph.addEdge(3, 1);
graph.addEdge(3, 4);
graph.addEdge(4, 1);
graph.addEdge(4, 3);
graph.addEdge(5, 1);
graph.addEdge(5, 6);
graph.addEdge(5, 8);
graph.addEdge(6, 5);
graph.addEdge(6, 7);
graph.addEdge(7, 6);
graph.addEdge(7, 8);
graph.addEdge(8, 5);
graph.addEdge(8, 7);
return graph;
}
}