Creation of edge set for a specific perfect matching number

조회 수: 2 (최근 30일)
Anthony Sirico
Anthony Sirico 2020년 11월 4일
답변: Jaynik 2024년 9월 27일
N = input('N='); %Number of vertices
J = 1:2:N-1 %odd numbers to N-1
P = [1, cumprod(J)] %Double Factorial
V = 1:1:N %available vertices
for j = J
q = (N+1-j)/2
I = ceil(I/P(:,q))
E(j) = V(end) %issue1
V(end)=[]
v(i) = ? %issue2
V(1) = []
I = I-((i-1)*P(:,q))
end
In the code above, specifically in the for loop, after i define I, i want to assign and remove the largest value in the array, and similarly to the smaller value. Then subtract to get an index in subgraph with 2 vertices removed. I am not familiar with the syntax for this.

답변 (1개)

Jaynik
Jaynik 2024년 9월 27일
Hi Anthony,
To select and remove the largest value from the V array in the for loop, you can do the following:
[maxValue, maxIndex] = max(V);
E(j) = maxValue;
V(maxIndex) = [];
You can do a similar step for the smallest values using the min function.
At the end, you can adjust the I as follows:
I = I - ((minIndex-1) * P(:,q));
Hope this helps!

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by