Advertisement
meta1211

Untitled

Dec 23rd, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. Leader *FindVertex(Leader *&Graph,int key)
  2. {
  3.     Leader *a = Graph;
  4.     while (a && a->key != key)
  5.     {
  6.         a = a->nx;
  7.     }
  8.     if (!a)
  9.     {
  10.         Leader *newLD = new Leader{ key, 0, Graph, nullptr };
  11.         Graph = newLD;
  12.         a = Graph;
  13.     }
  14.     return a;
  15. }
  16.  
  17. bool IsInTrailer(Trailer *tr, int key)
  18. {
  19.     for (Trailer *t = tr; t; t = t->nx)
  20.     {
  21.         if (t->ld->key == key)
  22.         {
  23.             return true;
  24.         }
  25.     }
  26.     return false;
  27. }
  28.  
  29. bool IsCompleteGraph(Leader *Graph, int a, int b, int c)
  30. {
  31.     Leader *Va = FindVertex(Graph, a);
  32.     Leader *Vb = FindVertex(Graph, b);
  33.     Leader *Vc = FindVertex(Graph, c);
  34.     return IsInTrailer(Va->tr, b) && IsInTrailer(Va->tr, c)
  35.         && IsInTrailer(Vb->tr, a) && IsInTrailer(Vb->tr, c)
  36.         && IsInTrailer(Vc->tr, a) && IsInTrailer(Vc->tr, b);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement