Stuff for matrix calc, need to fix adj matrix