A civ can trace a trade network path along roads/rails of another civ only if the two civ's are at PEACE. In this situation, if you're at war, the enemy wouldn't be able to access resouces in the surrounded city. If you made peace with them, though, he'd immediately gain access again, assuming...