An important issue in electroencephalography (EEG) experiments is to measure accurately the three dimensional (3D) positions of electrodes. We propose a system where these positions are automatically estimated from several images using computer vision techniques. Yet, only a set of undifferentiated points are recovered this way and remains the problem of labeling them, i.e. of finding which electrode corresponds to each point. This paper proposes a fast and robust solution to this latter problem based on combinatorial optimization. We design a specific energy that we minimize with a modified version of the Loopy Belief Propagation algorithm. Experiments on real data show that, with our method, a manual labeling of two or three electrodes only is sufficient to get the complete labeling of a 64 electrodes cap in less than 10 seconds. However, it is shown to be robust to missing electrodes in the reconstructed data.