public MasterGraph(Layer layer) {

		super();

		View view = layer.getParent();
		
		view.updateAlignmentData();
		ArrayList<ArrayList<Pair<Layer, Node>>> alignmentGroups = view.getAlignmentGroups();
		ArrayList<Node> masterNodes = new ArrayList<Node>();
		Hashtable<Node, Node> nodeToMasterNode = new Hashtable<Node, Node>();
		
		// Create master nodes
		int counter = 0;
		for (ArrayList<Pair<Layer, Node>> ag : alignmentGroups) {
			Node mn = new Node(""+counter);
			mn.prop.put("name", getGroupName(ag));
			Point2D.Double p = view.getAverageNodeCenter(ag);
			layer.setPositionInLayer(mn, p);
			counter++;
			masterNodes.add(mn);
			for (Pair<Layer, Node> ln : ag) {
				Node slave = ln.getValue();
				nodeToMasterNode.put(slave, mn);
				mn.slaves.add(ln);
///System.err.println(mn.getProp("name") + " -> " + slave.getProp("name"));
			}
		}
		
		// Re-create edges
		counter = 0;
		for (Layer l : view.getLayers()) {
			if (l instanceof MasterLayer)
				continue;
			Graph g = l.getGraph();
			for (Node n : g.getNodes()) {
				for (Edge e : n.getNeighbour()) {
					if (e.getSource() == n) {
//						n.getNeighbour().c
						Node mn1 = nodeToMasterNode.get(n);
						Node mn2 = nodeToMasterNode.get(e.getOtherNode(n));
						if (!mn1.getVoisins().contains(mn2)) {
							Edge me = new Edge(mn1.getId()+mn2.getId(), mn1, mn2);							
							mn1.edges.add(me);
							mn2.edges.add(me);
						}						
					}
				}
			}
			counter++;
		}
		
		// Add master nodes
		for (Node n : masterNodes)
			addNode(n);
	}