Contrary to popular opinion, a .gov and .edu domain name has no special significance to search engines. Google and the like do not especially favour such sites over any other.
It's likely that many sites run by government organisations or universities will have higher-quality content than, say, a typical blog. So such sites might well rank higher. But that's because of the content, not because the domain name ends in .gov or .edu.
The same applies to links from such sites. Getting a link from a .gov or .edu is not necessarily any better than a link from any other site of similar quality.