SlideShare a Scribd company logo
1 of 4
Download to read offline
%csv file containing edges and weights
e = csvread('edge.csv');
%finds number of edges
ne = length(e);
%makes sure vertices are in order
for i = 1:ne
if e(i,1) > e(i,2)
A = e(i,1);
e(i,1) = e(i,2);
e(i,2) = A;
e(i,3) = -e(i,3);
end
end
%creates vertex matrix
%finds number of vertices
nv = max(max([e(:,1), e(:,2)]));
V = zeros(1,nv);
for i = 1:ne
A = e(i,1);
B = e(i,2);
V(A) = V(A)+1;
V(B) = V(B)+1;
end
valence = max(V);
V = zeros(1,nv);
v = zeros(nv,valence);
for i = 1:ne
A = e(i,1);
B = e(i,2);
V(A) = V(A)+1;
V(B) = V(B)+1;
v(A,V(A)) = i;
v(B,V(B)) = i;
end
w = e(:,3);
%calculates edge weight
%w = zeros(ne,1);
%for p = 1:ne
% sum = 0;
% for i = 1:ne
% if e(i,1) == p || e(i,2) == p
% if e(i,1) == p
% sum = sum + e(i,3);
% end
% if e(i,2) == p
% sum = sum - e(i,3);
% end
% w(p,1) = sum;
% end
% end
%end
% Creates face matrix by searcing for shared edges of a triangle.
% Faces are stored as triples of vertices.
nf = 0;
for i = 1:ne
A = e(i,1); %end points of the selected min edge
B = e(i,2); %end points of the selected min edge
for j = v(A,:) %Edge number search
for k = v(B,:) %Edge number search
if j > i && k > i %-------------------
if e(j,1) == A % This area determines the 'other'
va = e(j,2); % vertex for each edge (j and k)
else % The goal is that these two match.
va = e(j,1); %
end %
if e(k,1) == B %
vb = e(k,2); %
else %
vb = e(k,1); %
end %-------------------
if va == vb && va ~= A && va ~= B %----------------
nf = nf +1; % This area checks
v1 = min([A,B,va]); % that the verts
v3 = max([A,B,va]); % are appropriate
for vert = [A,B,va] % then adds them
if v1 ~= vert && v3 ~= vert % to the faces
v2 = vert; % in the correct
end % orientation.
end %
f(nf,1) = v1; %
f(nf,2) = v2; %
f(nf,3) = v3; %
end %----------------
end
end
end
end
%initialize delta_0 and delta_1
delta_0 = zeros(ne,nv);
delta_1 = zeros(nf,ne);
temp = zeros(1,2);
%creates delta_0
%recall that delta_0(f)[v_1,v_2] = f(v_2) - f(v_1)
for i = 1:ne
delta_0(i,e(i,1))=-1;
delta_0(i,e(i,2))=1;
end
delta_0 = delta_0';
delta_0f = delta_0*w;
%creates delta_1
%recall that delta_1(f)[v_1,v_2,v_3] = f(v_2,v_3) - f(v_1,v_3) + f(v_1,v_2)
for i = 1:nf
%Computes f(v_2,v_3)
temp(1,1) = f(i,2);
temp(1,2) = f(i,3);
%Finds the corresponding edge
for k = 1:ne
if temp(1,1) == e(k,1)
if temp(1,2) == e(k,2)
j = k;
end
else
k=k+1;
end
end
delta_1(i,j) = 1;
%Computes f(v_1,v_3)
temp(1,1) = f(i,1);
temp(1,2) = f(i,3);
%Finds corresponding edge
for k = 1:ne
if temp(1,1) == e(k,1)
if temp(1,2) == e(k,2)
j = k;
end
else
k=k+1;
end
end
%-1 because ...-f(v_1,v_3)+...
delta_1(i,j) = -1;
%Computes f(v_1,v_2)
temp(1,1) = f(i,1);
temp(1,2) = f(i,2);
%Finds corresponding edge
for k = 1:ne
if temp(1,1) == e(k,1)
if temp(1,2) == e(k,2)
j = k;
end
else
k=k+1;
end
end
delta_1(i,j) = 1;
end
delta_1 = delta_1';
lap_0 = delta_0'*delta_0;
ONB = null(lap_0);
temp = size(ONB);
N = temp(2);
imvec = zeros(1,ne);
for i = 1:N
ort = ONB(:,i);
imvec = imvec + (w'*ort)*ort';
end
ee = zeros(ne,3);
for i = 1:ne %-------------------
ee(i,1) = e(i,1); % Assigns a new
ee(i,2) = e(i,2); % edge flow in
ee(i,3) = imvec(i); % Ker(Lapl).
end %-------------------
csvwrite('loops.csv',ee);
%display(imvec)
%display(w')

More Related Content

Viewers also liked

Viewers also liked (13)

Libro sig
Libro sigLibro sig
Libro sig
 
Final Masthead
Final MastheadFinal Masthead
Final Masthead
 
Project Management Trainings Survey
Project Management Trainings SurveyProject Management Trainings Survey
Project Management Trainings Survey
 
Sitecore 8 Azure PaaS Module Blueprint
Sitecore 8 Azure PaaS Module BlueprintSitecore 8 Azure PaaS Module Blueprint
Sitecore 8 Azure PaaS Module Blueprint
 
Aim Global OPP Nigeria Updated
Aim Global OPP Nigeria UpdatedAim Global OPP Nigeria Updated
Aim Global OPP Nigeria Updated
 
7. предметы
7. предметы7. предметы
7. предметы
 
Presentazione Dubli
Presentazione DubliPresentazione Dubli
Presentazione Dubli
 
Los coristas
Los coristasLos coristas
Los coristas
 
Applications at Scale
Applications at ScaleApplications at Scale
Applications at Scale
 
Johnson baby done !
Johnson baby done !Johnson baby done !
Johnson baby done !
 
Ali Abdulhamid fitbit Company Presentation
Ali Abdulhamid fitbit Company PresentationAli Abdulhamid fitbit Company Presentation
Ali Abdulhamid fitbit Company Presentation
 
ورقة عمل
ورقة عملورقة عمل
ورقة عمل
 
Saponification Presentation
Saponification PresentationSaponification Presentation
Saponification Presentation
 

Similar to HodgeCyce

3 (a) calculate thy potential at point P located a distance z above .pdf
 3 (a) calculate thy potential at point P located a distance z above  .pdf 3 (a) calculate thy potential at point P located a distance z above  .pdf
3 (a) calculate thy potential at point P located a distance z above .pdfInfo489948
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfaartechindia
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağıMerve Cvdr
 
Fourier series example
Fourier series exampleFourier series example
Fourier series exampleAbi finni
 
MATLAB Final Project
MATLAB Final ProjectMATLAB Final Project
MATLAB Final ProjectAlexis Ploss
 
FAIQ MANUAL.pdf
FAIQ MANUAL.pdfFAIQ MANUAL.pdf
FAIQ MANUAL.pdfFaiqAli57
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsEleanor McHugh
 
bask, bfsk, bpsk
bask, bfsk, bpskbask, bfsk, bpsk
bask, bfsk, bpskblzz2net
 
Please use the same variables and only write the TODO part #!-usr-bi.pdf
Please use the same variables and only write the TODO part   #!-usr-bi.pdfPlease use the same variables and only write the TODO part   #!-usr-bi.pdf
Please use the same variables and only write the TODO part #!-usr-bi.pdfasenterprisestyagi
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY MazedurMazedurr rahman
 
Help with root locus homework1
Help with root locus homework1Help with root locus homework1
Help with root locus homework1Assignmentpedia
 
Project filter matlab
Project  filter matlabProject  filter matlab
Project filter matlabgirma disasa
 
A Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter ThreeA Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter ThreeChung Hua Universit
 

Similar to HodgeCyce (19)

GreedyAlgorithm
GreedyAlgorithmGreedyAlgorithm
GreedyAlgorithm
 
3 (a) calculate thy potential at point P located a distance z above .pdf
 3 (a) calculate thy potential at point P located a distance z above  .pdf 3 (a) calculate thy potential at point P located a distance z above  .pdf
3 (a) calculate thy potential at point P located a distance z above .pdf
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
 
Capsizing
CapsizingCapsizing
Capsizing
 
Data Analysis
Data AnalysisData Analysis
Data Analysis
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
MATLAB Final Project
MATLAB Final ProjectMATLAB Final Project
MATLAB Final Project
 
Adaptive signal processing simon haykins
Adaptive signal processing simon haykinsAdaptive signal processing simon haykins
Adaptive signal processing simon haykins
 
Surface rendering
Surface renderingSurface rendering
Surface rendering
 
FAIQ MANUAL.pdf
FAIQ MANUAL.pdfFAIQ MANUAL.pdf
FAIQ MANUAL.pdf
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
bask, bfsk, bpsk
bask, bfsk, bpskbask, bfsk, bpsk
bask, bfsk, bpsk
 
Please use the same variables and only write the TODO part #!-usr-bi.pdf
Please use the same variables and only write the TODO part   #!-usr-bi.pdfPlease use the same variables and only write the TODO part   #!-usr-bi.pdf
Please use the same variables and only write the TODO part #!-usr-bi.pdf
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
 
matlab codes.pdf
matlab codes.pdfmatlab codes.pdf
matlab codes.pdf
 
Help with root locus homework1
Help with root locus homework1Help with root locus homework1
Help with root locus homework1
 
Project filter matlab
Project  filter matlabProject  filter matlab
Project filter matlab
 
A Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter ThreeA Course in Fuzzy Systems and Control Matlab Chapter Three
A Course in Fuzzy Systems and Control Matlab Chapter Three
 

HodgeCyce

  • 1. %csv file containing edges and weights e = csvread('edge.csv'); %finds number of edges ne = length(e); %makes sure vertices are in order for i = 1:ne if e(i,1) > e(i,2) A = e(i,1); e(i,1) = e(i,2); e(i,2) = A; e(i,3) = -e(i,3); end end %creates vertex matrix %finds number of vertices nv = max(max([e(:,1), e(:,2)])); V = zeros(1,nv); for i = 1:ne A = e(i,1); B = e(i,2); V(A) = V(A)+1; V(B) = V(B)+1; end valence = max(V); V = zeros(1,nv); v = zeros(nv,valence); for i = 1:ne A = e(i,1); B = e(i,2); V(A) = V(A)+1; V(B) = V(B)+1; v(A,V(A)) = i; v(B,V(B)) = i; end w = e(:,3); %calculates edge weight %w = zeros(ne,1); %for p = 1:ne % sum = 0; % for i = 1:ne % if e(i,1) == p || e(i,2) == p % if e(i,1) == p % sum = sum + e(i,3); % end % if e(i,2) == p % sum = sum - e(i,3); % end
  • 2. % w(p,1) = sum; % end % end %end % Creates face matrix by searcing for shared edges of a triangle. % Faces are stored as triples of vertices. nf = 0; for i = 1:ne A = e(i,1); %end points of the selected min edge B = e(i,2); %end points of the selected min edge for j = v(A,:) %Edge number search for k = v(B,:) %Edge number search if j > i && k > i %------------------- if e(j,1) == A % This area determines the 'other' va = e(j,2); % vertex for each edge (j and k) else % The goal is that these two match. va = e(j,1); % end % if e(k,1) == B % vb = e(k,2); % else % vb = e(k,1); % end %------------------- if va == vb && va ~= A && va ~= B %---------------- nf = nf +1; % This area checks v1 = min([A,B,va]); % that the verts v3 = max([A,B,va]); % are appropriate for vert = [A,B,va] % then adds them if v1 ~= vert && v3 ~= vert % to the faces v2 = vert; % in the correct end % orientation. end % f(nf,1) = v1; % f(nf,2) = v2; % f(nf,3) = v3; % end %---------------- end end end end %initialize delta_0 and delta_1 delta_0 = zeros(ne,nv); delta_1 = zeros(nf,ne); temp = zeros(1,2); %creates delta_0 %recall that delta_0(f)[v_1,v_2] = f(v_2) - f(v_1) for i = 1:ne delta_0(i,e(i,1))=-1; delta_0(i,e(i,2))=1; end delta_0 = delta_0';
  • 3. delta_0f = delta_0*w; %creates delta_1 %recall that delta_1(f)[v_1,v_2,v_3] = f(v_2,v_3) - f(v_1,v_3) + f(v_1,v_2) for i = 1:nf %Computes f(v_2,v_3) temp(1,1) = f(i,2); temp(1,2) = f(i,3); %Finds the corresponding edge for k = 1:ne if temp(1,1) == e(k,1) if temp(1,2) == e(k,2) j = k; end else k=k+1; end end delta_1(i,j) = 1; %Computes f(v_1,v_3) temp(1,1) = f(i,1); temp(1,2) = f(i,3); %Finds corresponding edge for k = 1:ne if temp(1,1) == e(k,1) if temp(1,2) == e(k,2) j = k; end else k=k+1; end end %-1 because ...-f(v_1,v_3)+... delta_1(i,j) = -1; %Computes f(v_1,v_2) temp(1,1) = f(i,1); temp(1,2) = f(i,2); %Finds corresponding edge for k = 1:ne if temp(1,1) == e(k,1) if temp(1,2) == e(k,2) j = k; end else k=k+1; end end delta_1(i,j) = 1; end delta_1 = delta_1'; lap_0 = delta_0'*delta_0; ONB = null(lap_0);
  • 4. temp = size(ONB); N = temp(2); imvec = zeros(1,ne); for i = 1:N ort = ONB(:,i); imvec = imvec + (w'*ort)*ort'; end ee = zeros(ne,3); for i = 1:ne %------------------- ee(i,1) = e(i,1); % Assigns a new ee(i,2) = e(i,2); % edge flow in ee(i,3) = imvec(i); % Ker(Lapl). end %------------------- csvwrite('loops.csv',ee); %display(imvec) %display(w')