You may try Poly_Connect tool to explore adjacency between triangles and find free edges - take a look onto implementation of Prs3d::AddFreeEdges() as example in src/Prs3d/Prs3d.cxx.
Or you may define a Map with Segment (as pair of sorted nodes indexes) as a key and Integer as a value, iterate over triangles and fill in the map by incrementing value for each key. Than you with this map you will be able to check if particular Segment is shared between triangles or not.
If we are talking about TopoDS_Face, than you may also iterate over TopoDS_Edge and use Poly_PolygonOnTriangulation representation of these Edges to filter out boundary segments in triangulation.