Potential Theory on Trees, Graphs and Ahlfors Regular Metric Spaces