Publishing sites are represented in Sharepoint by PublishinWeb class which has several convenient methods and properties for working with navigation (see my previous post about basics of navigation in Sharepoint). One of them is InheritGlobalNavigation property which contains boolean value showing whether publishing site inherits navigation from parent site or it has own navigation items (corresponds to “Display the navigation items below the current site“ option from Site Settings > Navigation).
But you can determine this property also for non-publishing sites represented by regular SPWeb class. Look inside InheritGlobalNavigation property:
Internally it reuses SPWeb.Navigation.UseShared property. So it is not necessary to obtain PublishingWeb instance if you only have SPWeb instance by extra call of PublishingWeb.GetPublishingWeb(SPWeb web) method. It is enough to have SPWeb instance and check Navigation.UseShared property.