sembrerebbe che usi il C++, prova a vedere se questa soluzione è conforme al tuo problema
codice:
#include <iostream>

typedef unsigned int UINT;

class TRIANGOLO
{

	UINT vx1;
	UINT vx2;
	UINT vx3;

	bool condivideVertice1 (TRIANGOLO t) {
		return (vx1 == t.vx1) || (vx1 == t.vx2) || (vx1 == t.vx3) ;
	}

	bool condivideVertice2 (TRIANGOLO t) {
		return (vx2 == t.vx1) || (vx2 == t.vx2) || (vx2 == t.vx3) ;
	}

	bool condivideVertice3 (TRIANGOLO t) {
		return (vx3 == t.vx1) || (vx3 == t.vx2) || (vx3 == t.vx3) ;
	}

public :

	TRIANGOLO (UINT * vet) :
		vx1(vet[0]), vx2(vet[1]), vx3(vet[2]) {
		}

	bool isAdiacent (TRIANGOLO t) {
		// è adiacente se condivide due vertici
		if ( (condivideVertice1(t) && condivideVertice2(t)) || (condivideVertice1(t) && condivideVertice3(t)) || (condivideVertice2(t) && condivideVertice3(t)) )
			return true;
		else
			return false;		
	}

};

int main ()
{

	UINT vet[] = {0, 1, 2, 2, 3, 4, 0, 2, 4, 0, 4, 5};

	UINT n_element = sizeof( vet ) / sizeof(UINT) ;
	UINT n_triangle = n_element / 3 ;

	for (int i = 0; i < n_triangle - 1; ++i) {
		// punta all'i-esimo triangolo
		TRIANGOLO t = vet + i * 3 ;
		for (int j = i + 1; j < n_triangle; ++j) {
			TRIANGOLO t1 = vet + j * 3 ;
			if ( t.isAdiacent(t1) ) {
				std::cout << "Triangolo " << i << " adiacente con " << j << std::endl;
			}
		}
	}


	return (0);

}