  Suppose the edges of $K_n$ are assigned weights by a weight function $w$. We
define the {\em weighted extremal number}
  \[
  \mathrm{ex}(n,w,F):=\max\{w(G)\mid G\subseteq K_n,\text{ and }G\text{ is
}F\text{-free}\}
  \]
  where $w(G):=\sum_{e\in E(G)}w(e)$. In this paper we study this problem for
two types of weights $w$, each of which has an application. The first
application is to an extremal problem in a complete multipartite host graph.
The second application is to the maximum rectilinear crossing number of trees
of diameter 4.
