comparison core/magnatagatune/macro_validate_cycle_finder.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1
2 % profile clear;
3 % profile on;
4
5 clear eval;
6 N = 20;
7 for ci = 1:N
8 order = ci;
9 % connectivity = ceil(rand(1) * order)
10 % E = mk_rnd_dag(order, connectivity);
11 E = rand(order) > exp(1) * rand(1);
12
13 G = DiGraph(ones(order,1), E);
14 eval.G(ci) = G;
15
16 eval.res_naive(ci) = acyclic(E);
17
18 eval.res_myfun(ci) = G.isAcyclic;
19
20 Gstob = ClipSimGraphStober(G);
21
22 eval.res_stober(ci) = Gstob.isAcyclic;
23 end
24 eval
25
26
27 figure
28 plot([eval.res_naive' eval.res_myfun'+0.1 eval.res_stober'+0.2],'*')
29 legend naive myfun stober
30 axis([0 N -1 2 ])
31 % profile viewer;
32
33 %%
34 % ---
35 % Comparison of implementations on magnatagatune dataset
36 % ---
37
38 % Stober Graph
39 Gstob = ClipSimGraphStober();
40
41 % Cast into matlab Graph
42 GstobG = Gstob.to_DiGraph;
43
44 % My Multigraph reimplementation
45 Gm = ClipSimGraphMulti(comparison, comparison_ids);
46
47 GstobG == Gm % TRUE - the converted Graph exactly resembles my extracted one
48
49 Gm.isAcyclic % FALSE
50 GstobG.isAcyclic % FALSE
51
52 Gstob.isAcyclic % TRUE (this is wrong, there are a lot of length-2-cycles)
53
54 % ---
55 % Ok, now remove length 2 cycles
56 % ---
57 Gm.remove_cycles_length2 % matlab cycle remover
58 Gstob.remove_cycles_length2 % stober cycle remover
59
60 GstobGnocycles = Gstob.to_DiGraph();
61
62 GstobGnocycles == Gm % TRUE - we remove the same edges
63
64 % ---
65 % NOTE: There are no cycles left
66 % after removing length 2 cycles
67 % ---
68 GstobGnocycles.isAcyclic % TRUE
69
70 Gstob.isAcyclic % FALSE inconsistent wrong result(compare with above)
71
72
73 %% Finds the actual defective cycle
74
75 Gstob = ClipSimGraphStober();
76 Gstob.remove_cycles_length2
77
78 GstobG = Gstob.to_DiGraph();
79 Gstob.isAcyclic
80
81 N = GstobG.node('227:45936');
82
83 [Gs] = GstobG.connected_components(N);
84 Gs.visualise
85
86 % ---
87 % Search same node in my Multigraph reimplementation
88 % ---
89 Gm = ClipSimGraphMulti(comparison, comparison_ids);
90 Gm.remove_cycles_length2
91 Nm = Gm.node(227,45936);
92
93 [Gsm] = Gm.connected_components(Nm);
94 Gsm.visualise