what is the m’kor and idea of lighting candles for
a. those who passed away; lo alenu, bar minan
b. tzaddikim ?
The custom of lighting candles is to show respect for the departed (see Berachos 53a), and as respect for Hashem (see Orchos Chaim 298:2, concerning lighting candles for Yom Kippur). Maharshal (Yam Shel Shlomo 46) writes that people are particular to follow this custom, and therefore it is permitted to tell a non-Jew to light the candles, if somebody forgot to do so before Shabbos.
The custom might also be related to the verse “for the candle of Hashem is the soul of man,” and our candles are therefore an appropriate memory for the departed.