Autogenerating a NavMesh

Hey everybody, I’m a little stuck here. I have a preexisting terrain mesh that I want to generate a navmesh for. I’m currently basing my process on that fact that all of the edges should not be shared by other polygons and that I have zero obstructions on the mesh. So basically I’m expecting to see just the perimeter after the generation.

Here’s the before mesh:
Imgur

Here’s the after mesh:
Imgur

As you can see it’s not quite what I’m expecting.

I’m getting all of the edges,

ArrayList<Edge> edges = new ArrayList<Edge>();
		for(int i = 0; i < layers.size(); i++)
		{
			Layer layer = layers.get(i);
			for(int j = 0; j < layer.getVertices().size() - 1; j++)
			{
				Edge edge = new Edge();
				edge.setOrigin(layer.getVertices().get(j+0).getPosition());
				edge.setDestination(layer.getVertices().get(j+1).getPosition());
				edges.add(edge);
			}
		}

In the “layer” the vertices are duplicated and in index order, meaning that indices don’t really mean anything and every three vertices is a triangle.

Anyway, then I remove the edges like so,

for(int i = 0; i < layers.size(); i++)
		{
			Layer layer = layers.get(i);
			for(int j = edges.size() - 1; j >= 0; j--)
			{
				Edge edge = edges.get(j);
				int count = 0;
				for(int k = 0; k < layer.getVertices().size(); k += 3)
				{
					Vertex v0 = layer.getVertices().get(k+0);
					Vertex v1 = layer.getVertices().get(k+1);
					Vertex v2 = layer.getVertices().get(k+2);
					if((edge.getOrigin().equals(v0.getPosition()) || 
						edge.getOrigin().equals(v1.getPosition()) ||
						edge.getOrigin().equals(v2.getPosition())
						) &&
						(edge.getDestination().equals(v0.getPosition()) || 
						edge.getDestination().equals(v1.getPosition()) ||
						edge.getDestination().equals(v2.getPosition())
						)
					) count++;
				}
				if(count > 1) edges.remove(edge);
			}
		}

edit: images…