how to test if there is a link to a specific node socket?
OK I've found out

for m in bpy.context.object.material_slots:
mat = m.material
if (mat.use_nodes):
    nodes = mat.node_tree.nodes
    links = mat.node_tree.links
    for n in nodes:
        if (n.type == 'BSDF_PRINCIPLED'):
            print(mat.name)
            alphasocket = n.inputs[18]
            if not(alphasocket.is_linked):
                print("No Alpha node!")     
            else:
                print("Alpha node connected")