Skip to content

Commit 16744e3

Browse files
committed
init commit
1 parent 77e4cdf commit 16744e3

File tree

277 files changed

+4097
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+4097
-0
lines changed

cuda_utils.cu

+512
Large diffs are not rendered by default.

deepmatting_seg.lua

+607
Large diffs are not rendered by default.

examples/input/in1.png

406 KB

examples/input/in10.png

446 KB

examples/input/in11.png

453 KB

examples/input/in12.png

453 KB

examples/input/in13.png

492 KB

examples/input/in14.png

467 KB

examples/input/in15.png

462 KB

examples/input/in16.png

184 KB

examples/input/in17.png

413 KB

examples/input/in18.png

261 KB

examples/input/in19.png

463 KB

examples/input/in2.png

146 KB

examples/input/in20.png

588 KB

examples/input/in21.png

654 KB

examples/input/in22.png

354 KB

examples/input/in23.png

354 KB

examples/input/in24.png

654 KB

examples/input/in25.png

492 KB

examples/input/in26.png

482 KB

examples/input/in27.png

564 KB

examples/input/in28.png

176 KB

examples/input/in29.png

409 KB

examples/input/in3.png

545 KB

examples/input/in30.png

595 KB

examples/input/in31.png

452 KB

examples/input/in32.png

402 KB

examples/input/in33.png

135 KB

examples/input/in34.png

489 KB

examples/input/in35.png

463 KB

examples/input/in36.png

250 KB

examples/input/in37.png

333 KB

examples/input/in38.png

269 KB

examples/input/in39.png

568 KB

examples/input/in4.png

545 KB

examples/input/in40.png

410 KB

examples/input/in41.png

553 KB

examples/input/in42.png

485 KB

examples/input/in43.png

573 KB

examples/input/in44.png

305 KB

examples/input/in45.png

495 KB

examples/input/in46.png

471 KB

examples/input/in47.png

377 KB

examples/input/in48.png

338 KB

examples/input/in49.png

338 KB

examples/input/in5.png

428 KB

examples/input/in50.png

489 KB

examples/input/in51.png

662 KB

examples/input/in52.png

744 KB

examples/input/in53.png

463 KB

examples/input/in54.png

729 KB

examples/input/in55.png

387 KB

examples/input/in56.png

444 KB

examples/input/in57.png

722 KB

examples/input/in58.png

464 KB

examples/input/in59.png

446 KB

examples/input/in6.png

430 KB

examples/input/in60.png

497 KB

examples/input/in7.png

356 KB

examples/input/in8.png

304 KB

examples/input/in9.png

354 KB

examples/segmentation/in1.png

26.6 KB

examples/segmentation/in10.png

25.1 KB

examples/segmentation/in11.png

55.8 KB

examples/segmentation/in12.png

55.8 KB

examples/segmentation/in13.png

16.2 KB

examples/segmentation/in14.png

34.3 KB

examples/segmentation/in15.png

24.6 KB

examples/segmentation/in16.png

30.2 KB

examples/segmentation/in17.png

33.9 KB

examples/segmentation/in18.png

40.5 KB

examples/segmentation/in19.png

23.5 KB

examples/segmentation/in2.png

12.6 KB

examples/segmentation/in20.png

32.5 KB

examples/segmentation/in21.png

32.5 KB

examples/segmentation/in22.png

15.1 KB

examples/segmentation/in23.png

37 KB

examples/segmentation/in24.png

33.8 KB

examples/segmentation/in25.png

64.3 KB

examples/segmentation/in26.png

27.9 KB

examples/segmentation/in27.png

38.3 KB

examples/segmentation/in28.png

26.7 KB

examples/segmentation/in29.png

15.9 KB

examples/segmentation/in3.png

21.2 KB

examples/segmentation/in30.png

27.2 KB

examples/segmentation/in31.png

10.1 KB

examples/segmentation/in32.png

9.83 KB

examples/segmentation/in33.png

42.4 KB

examples/segmentation/in34.png

33.6 KB

examples/segmentation/in35.png

55.8 KB

examples/segmentation/in36.png

40.8 KB

examples/segmentation/in37.png

34.6 KB

examples/segmentation/in38.png

37.7 KB

examples/segmentation/in39.png

31.8 KB

examples/segmentation/in4.png

21.2 KB

examples/segmentation/in40.png

52.1 KB

examples/segmentation/in41.png

39.8 KB

examples/segmentation/in42.png

44.1 KB

examples/segmentation/in43.png

51.5 KB

examples/segmentation/in44.png

44.3 KB

examples/segmentation/in45.png

48 KB

examples/segmentation/in46.png

57.5 KB

examples/segmentation/in47.png

22.2 KB

examples/segmentation/in48.png

13.2 KB

examples/segmentation/in49.png

13.2 KB

examples/segmentation/in5.png

29.8 KB

examples/segmentation/in50.png

30.8 KB

examples/segmentation/in51.png

26 KB

examples/segmentation/in52.png

42.6 KB

examples/segmentation/in53.png

12.2 KB

examples/segmentation/in54.png

20.2 KB

examples/segmentation/in55.png

108 KB

examples/segmentation/in56.png

8.62 KB

examples/segmentation/in57.png

1.96 KB

examples/segmentation/in58.png

13.1 KB

examples/segmentation/in59.png

35.6 KB

examples/segmentation/in6.png

34.8 KB

examples/segmentation/in60.png

30.9 KB

examples/segmentation/in7.png

23.9 KB

examples/segmentation/in8.png

20.6 KB

examples/segmentation/in9.png

15.4 KB

examples/segmentation/tar1.png

36.5 KB

examples/segmentation/tar10.png

20.8 KB

examples/segmentation/tar11.png

47.3 KB

examples/segmentation/tar12.png

48.5 KB

examples/segmentation/tar13.png

18.2 KB

examples/segmentation/tar14.png

30.5 KB

examples/segmentation/tar15.png

27.9 KB

examples/segmentation/tar16.png

35 KB

examples/segmentation/tar17.png

25.2 KB

examples/segmentation/tar18.png

41.7 KB

examples/segmentation/tar19.png

18.1 KB

examples/segmentation/tar2.png

25.7 KB

examples/segmentation/tar20.png

26.2 KB

examples/segmentation/tar21.png

33.6 KB

examples/segmentation/tar22.png

16.1 KB

examples/segmentation/tar23.png

36.4 KB

examples/segmentation/tar24.png

25.2 KB

examples/segmentation/tar25.png

68.9 KB

examples/segmentation/tar26.png

32.1 KB

examples/segmentation/tar27.png

27.4 KB

examples/segmentation/tar28.png

50.9 KB

examples/segmentation/tar29.png

9.81 KB

examples/segmentation/tar3.png

29.5 KB

examples/segmentation/tar30.png

40 KB

examples/segmentation/tar31.png

6.94 KB

examples/segmentation/tar32.png

114 KB

examples/segmentation/tar33.png

17.2 KB

examples/segmentation/tar34.png

29 KB

examples/segmentation/tar35.png

50.7 KB

examples/segmentation/tar36.png

34 KB

examples/segmentation/tar37.png

38.8 KB

examples/segmentation/tar38.png

36.2 KB

examples/segmentation/tar39.png

57.4 KB

examples/segmentation/tar4.png

15.9 KB

examples/segmentation/tar40.png

47.3 KB

examples/segmentation/tar41.png

51.6 KB

examples/segmentation/tar42.png

75.3 KB

examples/segmentation/tar43.png

50.5 KB

examples/segmentation/tar44.png

43.3 KB

examples/segmentation/tar45.png

47.6 KB

examples/segmentation/tar46.png

14.8 KB

examples/segmentation/tar47.png

6.42 KB

examples/segmentation/tar48.png

44.4 KB

examples/segmentation/tar49.png

34 KB

examples/segmentation/tar5.png

19.8 KB

examples/segmentation/tar50.png

43.1 KB

examples/segmentation/tar51.png

51.5 KB

examples/segmentation/tar52.png

20.6 KB

examples/segmentation/tar53.png

112 KB

examples/segmentation/tar54.png

34.8 KB

examples/segmentation/tar55.png

35.3 KB

examples/segmentation/tar56.png

35.3 KB

examples/segmentation/tar57.png

1.86 KB

examples/segmentation/tar58.png

58.2 KB

examples/segmentation/tar59.png

15.2 KB

examples/segmentation/tar6.png

47.5 KB

examples/segmentation/tar60.png

62.4 KB

examples/segmentation/tar7.png

22.9 KB

examples/segmentation/tar8.png

15.9 KB

examples/segmentation/tar9.png

15.1 KB

examples/style/tar1.png

318 KB

examples/style/tar10.png

561 KB

examples/style/tar11.png

443 KB

examples/style/tar12.png

257 KB

examples/style/tar13.png

511 KB

examples/style/tar14.png

497 KB

examples/style/tar15.png

574 KB

examples/style/tar16.png

248 KB

examples/style/tar17.png

218 KB

examples/style/tar18.png

185 KB

examples/style/tar19.png

598 KB

examples/style/tar2.png

164 KB

examples/style/tar20.png

367 KB

examples/style/tar21.png

766 KB

examples/style/tar22.png

561 KB

examples/style/tar23.png

354 KB

examples/style/tar24.png

490 KB

examples/style/tar25.png

411 KB

examples/style/tar26.png

711 KB

examples/style/tar27.png

362 KB

examples/style/tar28.png

557 KB

examples/style/tar29.png

546 KB

examples/style/tar3.png

431 KB

examples/style/tar30.png

595 KB

examples/style/tar31.png

532 KB

examples/style/tar32.png

557 KB

examples/style/tar33.png

534 KB

examples/style/tar34.png

741 KB

examples/style/tar35.png

375 KB

examples/style/tar36.png

95.8 KB

examples/style/tar37.png

523 KB

examples/style/tar38.png

133 KB

examples/style/tar39.png

718 KB

examples/style/tar4.png

369 KB

examples/style/tar40.png

289 KB

examples/style/tar41.png

467 KB

examples/style/tar42.png

559 KB

examples/style/tar43.png

654 KB

examples/style/tar44.png

580 KB

examples/style/tar45.png

414 KB

examples/style/tar46.png

135 KB

examples/style/tar47.png

142 KB

examples/style/tar48.png

400 KB

examples/style/tar49.png

445 KB

examples/style/tar5.png

296 KB

examples/style/tar50.png

509 KB

examples/style/tar51.png

590 KB

examples/style/tar52.png

330 KB

examples/style/tar53.png

628 KB

examples/style/tar54.png

600 KB

examples/style/tar55.png

245 KB

examples/style/tar56.png

572 KB

examples/style/tar57.png

723 KB

examples/style/tar58.png

541 KB

examples/style/tar59.png

408 KB

examples/style/tar6.png

361 KB

examples/style/tar60.png

600 KB

examples/style/tar7.png

392 KB

examples/style/tar8.png

217 KB

examples/style/tar9.png

390 KB

gen_all.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import math
3+
4+
# number of GPUs available
5+
numGpus = 8
6+
7+
# number of image pairs to process
8+
numImgs = 60
9+
10+
N = int(math.ceil(float(numImgs)/numGpus))
11+
for j in range(1, numGpus + 1):
12+
cmd = ''
13+
14+
for i in range(1, N + 1):
15+
idx = (i-1) * numGpus + j
16+
if idx <= numImgs:
17+
print 'working on image pair index = ' + str(idx)
18+
19+
part1_cmd = ' th neuralstyle_seg.lua -content_image examples/input/in'+str(idx)+'.png -style_image examples/style/tar'+str(idx)+'.png -content_seg examples/segmentation/in'+str(idx)+'.png -style_seg examples/segmentation/tar'+str(idx)+'.png -index '+str(idx)+' -num_iterations 1000 -save_iter 100 -print_iter 1 -gpu '+str(j-1)+' -serial examples/tmp_results &&'
20+
21+
part2_cmd = ' th deepmatting_seg.lua -content_image examples/input/in'+str(idx)+'.png -style_image examples/style/tar'+str(idx)+'.png -init_image examples/tmp_results/out'+str(idx)+'\_t_1000.png -content_seg examples/segmentation/in'+str(idx)+'.png -style_seg examples/segmentation/tar'+str(idx)+'.png -index '+str(idx)+' -num_iterations 1000 -save_iter 100 -print_iter 1 -gpu '+str(j-1)+' -serial examples/final_results -f_radius 15 -f_edge 0.01 &&'
22+
23+
cmd = cmd + part1_cmd + part2_cmd
24+
25+
cmd = cmd[1:len(cmd)-1]
26+
print(cmd)
27+
os.system(cmd)
28+
29+

gen_laplacian/gaimc/Contents.m

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
%=========================================
2+
% Graph Algorithms in Matlab Code (gaimc)
3+
% Written by David Gleich
4+
% Version 1.0 (beta)
5+
% 2008-2009
6+
%=========================================
7+
%
8+
% Search algorithms
9+
% dfs - depth first search
10+
% bfs - breadth first search
11+
%
12+
% Shortest path algorithms
13+
% dijkstra - Dijkstra's shortest path algorithm
14+
%
15+
% Minimum spanning tree algorithms
16+
% mst_prim - Compute an MST using Prim's algorithm
17+
%
18+
% Matching
19+
% bipartite_matching - Compute a maximum weight bipartite matching
20+
%
21+
% Connected components
22+
% scomponents - Compute strongly connected components
23+
% largest_component - Selects only the largest component
24+
%
25+
% Statistics
26+
% clustercoeffs - Compute clustering coefficients
27+
% dirclustercoeffs - Compute directed clustering coefficients
28+
% corenums - Compute core numbers
29+
%
30+
% Drawing
31+
% graph_draw - Draw an adjacency matrix (from Leon Peshkin)
32+
%
33+
% Helper functions
34+
% sparse_to_csr - Compressed sparse row arrays from a matrix
35+
% csr_to_sparse - Convert back to Matlab sparse matrices
36+
% load_gaimc_graph - Loads a sample graph from the library
37+
38+
% David F. Gleich
39+
% Copyright, Stanford University, 2008-2009
40+
41+
% History
42+
% 2008-04-10: Initial version
43+
44+
45+
% TODO for release
46+
% Fix mlintrpt errors
47+
48+
49+
% Future todos
50+
% Implement weighted core nums
51+
% More testing
52+
% Implement all pairs shortest paths with Floyd Warshall

gen_laplacian/gaimc/bfs.m

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
function [d dt pred] = bfs(A,u,target)
2+
% BFS Compute breadth first search distances, times, and tree for a graph
3+
%
4+
% [d dt pred] = bfs(A,u) returns the distance (d) and the discover time
5+
% (dt) for each vertex in the graph in a breadth first search
6+
% starting from vertex u.
7+
% d = dt(i) = -1 if vertex i is not reachable from u
8+
% pred is the predecessor array. pred(i) = 0 if vertex (i)
9+
% is in a component not reachable from u and i != u.
10+
%
11+
% [...] = bfs(A,u,v) stops the bfs when it hits the vertex v
12+
%
13+
% Example:
14+
% load_gaimc_graph('bfs_example.mat') % use the dfs example from Boost
15+
% d = bfs(A,1)
16+
%
17+
% See also DFS
18+
19+
% David F. Gleich
20+
% Copyright, Stanford University, 2008-20098
21+
22+
% History
23+
% 2008-04-13: Initial coding
24+
25+
if ~exist('target','var') || isempty(full), target=0; end
26+
27+
if isstruct(A), rp=A.rp; ci=A.ci;
28+
else [rp ci]=sparse_to_csr(A);
29+
end
30+
31+
n=length(rp)-1;
32+
d=-1*ones(n,1); dt=-1*ones(n,1); pred=zeros(1,n);
33+
sq=zeros(n,1); sqt=0; sqh=0; % search queue and search queue tail/head
34+
35+
% start bfs at u
36+
sqt=sqt+1; sq(sqt)=u;
37+
t=0;
38+
d(u)=0; dt(u)=t; t=t+1; pred(u)=u;
39+
while sqt-sqh>0
40+
sqh=sqh+1; v=sq(sqh); % pop v off the head of the queue
41+
for ri=rp(v):rp(v+1)-1
42+
w=ci(ri);
43+
if d(w)<0
44+
sqt=sqt+1; sq(sqt)=w;
45+
d(w)=d(v)+1; dt(w)=t; t=t+1; pred(w)=v;
46+
if w==target, return; end
47+
end
48+
end
49+
end
+240
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
function [val m1 m2 mi]=bipartite_matching(varargin)
2+
% BIPARTITE_MATCHING Solve a maximum weight bipartite matching problem
3+
%
4+
% [val m1 m2]=bipartite_matching(A) for a rectangular matrix A
5+
% [val m1 m2 mi]=bipartite_matching(x,ei,ej,n,m) for a matrix stored
6+
% in triplet format. This call also returns a matching indicator mi so
7+
% that val = x'*mi.
8+
%
9+
% The maximum weight bipartite matching problem tries to pick out elements
10+
% from A such that each row and column get only a single non-zero but the
11+
% sum of all the chosen elements is as large as possible.
12+
%
13+
% This function is slightly atypical for a graph library, because it will
14+
% be primarily used on rectangular inputs. However, these rectangular
15+
% inputs model bipartite graphs and we take advantage of that stucture in
16+
% this code. The underlying graph adjency matrix is
17+
% G = spaugment(A,0);
18+
% where A is the rectangular input to the bipartite_matching function.
19+
%
20+
% Matlab already has the dmperm function that computes a maximum
21+
% cardinality matching between the rows and the columns. This function
22+
% gives us the maximum weight matching instead. For unweighted graphs, the
23+
% two functions are equivalent.
24+
%
25+
% Note: If ei and ej contain duplicate edges, the results of this function
26+
% are incorrect.
27+
%
28+
% See also DMPERM
29+
%
30+
% Example:
31+
% A = rand(10,8); % bipartite matching between random data
32+
% [val mi mj] = bipartite_matching(A);
33+
% val
34+
35+
% David F. Gleich and Ying Wang
36+
% Copyright, Stanford University, 2008-2009
37+
% Computational Approaches to Digital Stewardship
38+
39+
% 2008-04-24: Initial coding (copy from Ying Wang matching_sparse_mex.cpp)
40+
% 2008-11-15: Added triplet input/output
41+
% 2009-04-30: Modified for gaimc library
42+
% 2009-05-15: Fixed error with empty inputs and triple added example.
43+
44+
[rp ci ai tripi n m] = bipartite_matching_setup(varargin{:});
45+
46+
if isempty(tripi)
47+
error(nargoutchk(0,3,nargout,'struct'));
48+
else
49+
error(nargoutchk(0,4,nargout,'struct'));
50+
end
51+
52+
53+
if ~isempty(tripi) && nargout>3
54+
[val m1 m2 mi] = bipartite_matching_primal_dual(rp, ci, ai, tripi, n, m);
55+
else
56+
[val m1 m2] = bipartite_matching_primal_dual(rp, ci, ai, tripi, n, m);
57+
end
58+
59+
function [rp ci ai tripi n m]= bipartite_matching_setup(A,ei,ej,n,m)
60+
% convert the input
61+
62+
if nargin == 1
63+
if isstruct(A)
64+
[nzi nzj nzv]=csr_to_sparse(A.rp,A.ci,A.ai);
65+
else
66+
[nzi nzj nzv]=find(A);
67+
end
68+
[n m]=size(A);
69+
triplet = 0;
70+
elseif nargin >= 3 && nargin <= 5
71+
nzi = ei;
72+
nzj = ej;
73+
nzv = A;
74+
if ~exist('n','var') || isempty(n), n = max(nzi); end
75+
if ~exist('m','var') || isempty(m), m = max(nzj); end
76+
triplet = 1;
77+
else
78+
error(nargchk(3,5,nargin,'struct'));
79+
end
80+
nedges = length(nzi);
81+
82+
rp = ones(n+1,1); % csr matrix with extra edges
83+
ci = zeros(nedges+n,1);
84+
ai = zeros(nedges+n,1);
85+
if triplet, tripi = zeros(nedges+n,1); % triplet index
86+
else tripi = [];
87+
end
88+
89+
%
90+
% 1. build csr representation with a set of extra edges from vertex i to
91+
% vertex m+i
92+
%
93+
rp(1)=0;
94+
for i=1:nedges
95+
rp(nzi(i)+1)=rp(nzi(i)+1)+1;
96+
end
97+
rp=cumsum(rp);
98+
for i=1:nedges
99+
if triplet, tripi(rp(nzi(i))+1)=i; end % triplet index
100+
ai(rp(nzi(i))+1)=nzv(i);
101+
ci(rp(nzi(i))+1)=nzj(i);
102+
rp(nzi(i))=rp(nzi(i))+1;
103+
end
104+
for i=1:n % add the extra edges
105+
if triplet, tripi(rp(i)+1)=-1; end % triplet index
106+
ai(rp(i)+1)=0;
107+
ci(rp(i)+1)=m+i;
108+
rp(i)=rp(i)+1;
109+
end
110+
% restore the row pointer array
111+
for i=n:-1:1
112+
rp(i+1)=rp(i);
113+
end
114+
rp(1)=0;
115+
rp=rp+1;
116+
117+
%
118+
% 1a. check for duplicates in the data
119+
%
120+
colind = false(m+n,1);
121+
for i=1:n
122+
for rpi=rp(i):rp(i+1)-1
123+
if colind(ci(rpi)), error('bipartite_matching:duplicateEdge',...
124+
'duplicate edge detected (%i,%i)',i,ci(rpi));
125+
end
126+
colind(ci(rpi))=1;
127+
end
128+
for rpi=rp(i):rp(i+1)-1, colind(ci(rpi))=0; end % reset indicator
129+
end
130+
131+
132+
function [val m1 m2 mi]=bipartite_matching_primal_dual(...
133+
rp, ci, ai, tripi, n, m)
134+
% BIPARTITE_MATCHING_PRIMAL_DUAL
135+
136+
alpha=zeros(n,1); % variables used for the primal-dual algorithm
137+
beta=zeros(n+m,1);
138+
queue=zeros(n,1);
139+
t=zeros(n+m,1);
140+
match1=zeros(n,1);
141+
match2=zeros(n+m,1);
142+
tmod = zeros(n+m,1);
143+
ntmod=0;
144+
145+
146+
%
147+
% initialize the primal and dual variables
148+
%
149+
for i=1:n
150+
for rpi=rp(i):rp(i+1)-1
151+
if ai(rpi) > alpha(i), alpha(i)=ai(rpi); end
152+
end
153+
end
154+
% dual variables (beta) are initialized to 0 already
155+
% match1 and match2 are both 0, which indicates no matches
156+
i=1;
157+
while i<=n
158+
% repeat the problem for n stages
159+
160+
% clear t(j)
161+
for j=1:ntmod, t(tmod(j))=0; end
162+
ntmod=0;
163+
164+
165+
% add i to the stack
166+
head=1; tail=1;
167+
queue(head)=i; % add i to the head of the queue
168+
while head <= tail && match1(i)==0
169+
k=queue(head);
170+
for rpi=rp(k):rp(k+1)-1
171+
j = ci(rpi);
172+
if ai(rpi) < alpha(k)+beta(j) - 1e-8, continue; end % skip if tight
173+
if t(j)==0,
174+
tail=tail+1; queue(tail)=match2(j);
175+
t(j)=k;
176+
ntmod=ntmod+1; tmod(ntmod)=j;
177+
if match2(j)<1,
178+
while j>0,
179+
match2(j)=t(j);
180+
k=t(j);
181+
temp=match1(k);
182+
match1(k)=j;
183+
j=temp;
184+
end
185+
break; % we found an alternating path
186+
end
187+
end
188+
end
189+
head=head+1;
190+
end
191+
192+
if match1(i) < 1, % still not matched, so update primal, dual and repeat
193+
theta=inf;
194+
for j=1:head-1
195+
t1=queue(j);
196+
for rpi=rp(t1):rp(t1+1)-1
197+
t2=ci(rpi);
198+
if t(t2) == 0 && alpha(t1) + beta(t2) - ai(rpi) < theta,
199+
theta = alpha(t1) + beta(t2) - ai(rpi);
200+
end
201+
end
202+
end
203+
204+
for j=1:head-1, alpha(queue(j)) = alpha(queue(j)) - theta; end
205+
206+
for j=1:ntmod, beta(tmod(j)) = beta(tmod(j)) + theta; end
207+
208+
continue;
209+
end
210+
211+
i=i+1; % increment i
212+
end
213+
214+
val=0;
215+
for i=1:n
216+
for rpi=rp(i):rp(i+1)-1
217+
if ci(rpi)==match1(i), val=val+ai(rpi); end
218+
end
219+
end
220+
noute = 0; % count number of output edges
221+
for i=1:n
222+
if match1(i)<=m, noute=noute+1; end
223+
end
224+
m1=zeros(noute,1); m2=m1; % copy over the 0 array
225+
noute=1;
226+
for i=1:n
227+
if match1(i)<=m, m1(noute)=i; m2(noute)=match1(i);noute=noute+1; end
228+
end
229+
230+
if nargout>3
231+
mi= false(length(tripi)-n,1);
232+
for i=1:n
233+
for rpi=rp(i):rp(i+1)-1
234+
if match1(i)<=m && ci(rpi)==match1(i), mi(tripi(rpi))=1; end
235+
end
236+
end
237+
end
238+
239+
240+

0 commit comments

Comments
 (0)