There are two concepts at work here: graph topology and level geometry (aka topography). They're two sides of the same coin.
Furthermore, there are two ways your levels could be produced: manually or procedurally.
In the manual case where you have level designers constructing your (static) levels, the simplest and most sensible solution is to simply have them specify via editor or data file, nodes that represent portals inside your pathing graph. Obviously in this case it is also up to level designers to ensure that the geometry of the level is suited to that pathing which is put in place (usually you would do the level geom first, then lay pathing nodes over that to ensure the nodes are in all the right places and no others).
In the procedural case, or in a case where your initial level may be manually-constructed, but can be changed later (as is the case with destructible terrain), you need intelligence built in to detect what might be considered a "portal". This sounds a lot easier than it actually is, geometrically speaking. Consider a cave complex constructed, throughout, of the same homogenous material. Say you use some form of noise to generate spaces inside a level-sized block of solid rock, and then used some sort of coherence/metaball approach to join the closest points of these spaces. Now some of these join channels are going to be narrower than others, and in different places. You can see how the shape of entities can also affect where they might be able to traverse and where they might not. This is quite a problem in 3D; in 2D, it's a lot easier to handle but still not trivial. One way to make things easier in both cases is to assume either a square (cubic) or circular (spherical) bounding volume for each entity.
One way to identify portals is to exhaustively cast rays around a circular or spherical shell whose diameter is equal to the minimum width needed for an entity to pass through (i.e. their body width). In order to limit the number of locations to do such a test from (to something less than infinity), it's a good idea to quantise your level space into a grid. Even so, this is very time-consuming in both cases, especially in 3D, and if possible should be done once only, and cached. Of course, that is easier said than done if your level geometry is indeed dynamic. Another way to visualise this casting of ray to a shell, is to see it as the placement of an "atom" into a tiny open space, and growing that atom until is hits the surround rock, like a balloon expanding.
The point I'm getting at is that while a portal is pretty much instantly recognised by any higher animal (our facility probably being due to natural selection, since quickly identifying hiding places had to have been crucial), there is actually a lot of raw logic that goes into determining where a body of a given set of dimensions can pass, and where it can't.