change dict to adj matrix, construct mat A