  Topology recognition and leader election are fundamental tasks in distributed
computing in networks. The first of them requires each node to find a labeled
isomorphic copy of the network, while the result of the second one consists in
a single node adopting the label 1 (leader), with all other nodes adopting the
label 0 and learning a path to the leader. We consider both these problems in
networks whose nodes are equipped with not necessarily distinct labels called
colors, and ports at each node of degree $d$ are arbitrarily numbered
$0,1,\dots, d-1$. Colored networks are generalizations both of labeled networks
and anonymous networks.
  In colored networks, topology recognition and leader election are not always
feasible. Hence we study two more general problems. The aim of the problem TOP
(resp. LE), for a colored network and for input $I$ given to its nodes, is to
solve topology recognition (resp. leader election) in this network, if this is
possible under input $I$, and to have all nodes answer "unsolvable" otherwise.
  We show that nodes of a network can solve problems TOP and LE, if they are
given, as input $I$, an upper bound $k$ on the number of nodes of a given
color, called the size of this color. On the other hand we show that, if the
nodes are given an input that does not bound the size of any color, then the
answer to TOP and LE must be "unsolvable", even for the class of rings.
  Under the assumption that nodes are given an upper bound $k$ on the size of a
given color, we study the time of solving problems TOP and LE in the $LOCAL$.
We give an algorithm to solve each of these problems in arbitrary $n$-node
networks of diameter $D$ in time $O(kD+D\log(n/D))$. We also show that this
time is optimal, by exhibiting classes of networks in which every algorithm
solving problems TOP or LE must use time $\Omega(kD+D\log(n/D))$.
