  We introduce a generalized worldline model where the partition function is a
sum over configurations of a conserved flux on a d-dimensional lattice. The
weights for the configurations of the corresponding worldlines have factors
living on the links of the lattice, as well as terms which live on the sites x
and depend on all fluxes attached to x. The model represents a general class of
worldline systems, among them the dual representation of the relativistic Bose
gas at finite density. We construct a suitable worm algorithm and show how to
correctly distribute the site weights in the various Metropolis probabilities
that determine the worm. We analyze the algorithm in detail and give a proof of
detailed balance. Our algorithm admits the introduction of an amplitude
parameter A that can be chosen freely. Using a numerical simulation of the
relativistic Bose gas we demonstrate that A allows one to influence the
starting and terminating probabilities and thus the average length and the
efficiency of the worm.
