当前位置:网站首页>Complete diagram / Euler loop

Complete diagram / Euler loop

2022-06-26 14:23:00 Honestbutter-

link

Complete graph : A complete graph is a simple undirected graph , Each edge has a different pair of vertices . Complete graphs have at most n*(n-1)/2 side

Find the minimum and maximum of the longest path :
minimum value : First, the longest path cannot have a ring , Otherwise it will be infinite , So in the acyclic case , Every point goes through once , The minimum value of the longest path is n − 1 n-1 n1
Maximum : Go all the way —— Euler circuit , And because the Euler circuit of an undirected graph has at most ( n − 1 ) n / 2 (n-1)n/2 (n1)n/2 side , The Euler loop requires that the points of odd degree of an undirected graph have at most 2 individual , Discussion on odd and even points

  1. Odd points : n n n It's odd , ( n − 1 ) (n-1) (n1) For the even , therefore n n n An odd number of points. Each point has ( n − 1 ) (n-1) (n1) Even edges , Conform to Euler circuit , The length is ( n − 1 ) n / 2 (n-1)n/2 (n1)n/2
  2. Even points : even numbers n n n One point is ( n − 1 ) (n-1) (n1) Odd edges , Because there are at most two odd sides , So there is ( n − 2 ) (n-2) (n2) A dot needs to delete an edge , Because an undirected graph , So a total of ( n − 2 ) / 2 (n-2)/2 (n2)/2 side , The length is ( n − 1 ) n / 2 − ( n − 2 ) / 2 (n-1)n/2-(n-2)/2 (n1)n/2(n2)/2
#include<iostream>
using namespace std;

int main()
{
    
    long long n;
    cin>>n;
    
    if(n&1) cout<<n-1<<" "<<(n-1)*n/2<<endl;
    else cout<<n-1<<" "<<(n-1)*n/2-(n-2)/2<<endl;
    
    return 0;
}


原网站

版权声明
本文为[Honestbutter-]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170508103436.html