Pagerank flow equally to all links(internal/external). But there are other link metrics as well, which calculate page expert/trust score and domain trust score. Google does not disclose anything about that, but generally we assume relevance backlinks means higher position in SERP.
When you link your domain.com to sub.domain.com or vice versa, then Google will recognize that as internal links. And internal links in nav/footer/sidebar does not consider as spam links. So that is your answer.
It also fine when you link your otherdomain.com from domain.com or vice versa, because Google consider that as affiliate links (Not talking about affiliate links for monetization). Here Stackoverflow and stackexchange footer/sidbar links are consider as affiliate links, and it will don't pass trust score to those links, but PageRank will flow equality to all links and so on Google crawl all the webpages very efficiently.
Google generally pass less or no trust score value when they see affiliate links. Here is small list how google consider that as affiliate links.
- When both domain have same who is data.
- When both domain use same search console account.
- When both domain is hosted on same IP.
- When both domain are inter-linked from nav/footer/sidebar.
Almost all links pass PageRank, but trust score only pass when non-affiliate website links to you naturally.
Remember that, Links also have different attribute like nofollow and dofollow, and Pagerank on those links may pass differently. Also many webmaster said that links on body page may pass more Pagerank compare to nav/footer links. Google PR algorithm is top secreat, so no one really know how it's works.