Skip to content

Commit

Permalink
Add function IsSymmetricGraph to the GraphicalFunctions.h
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuDutSik committed Dec 25, 2023
1 parent 2990c5f commit ff4ec3c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src_graph/GRAPH_GraphicalFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,25 @@ template <typename Tgr> bool IsSimpleGraph(Tgr const &GR) {
return true;
}

template <typename Tgr> bool IsSymmetricGraph(Tgr const &GR) {
size_t nbVert = GR.GetNbVert();
MyMatrix<int8_t> M=ZeroMatrix<int8_t>(nbVert,nbVert);
for (size_t iVert = 0; iVert < nbVert; iVert++) {
std::vector<size_t> LAdj = GR.Adjacency(iVert);
for (auto & eAdj : LAdj) {
M(iVert, eAdj) = 1;
}
}
for (size_t iVert=0; iVert<nbVert; iVert++) {
for (size_t jVert=iVert+1; jVert<nbVert; jVert++) {
if (M(iVert, jVert) != M(jVert, iVert)) {
return false;
}
}
}
return true;
}

template <typename Tgr>
std::vector<std::vector<size_t>> GetEdgeSet(Tgr const &GR) {
size_t nbVert = GR.GetNbVert();
Expand Down

0 comments on commit ff4ec3c

Please sign in to comment.