def get_nodename(soname, nodenames):
  """Generate DOT nodename."""
  if soname in nodenames:
    return nodenames[soname]
  nn = len(nodenames)
  seed = "".join([x if x.isalnum() else "_" for x in soname])
  nn = "%s_%d" % (seed, nn)
  nodenames[soname] = nn
  return nn