public static Map<Integer, ZState> createStates(List<Connection> connections){
        Map<Integer, ZState> states = new HashMap<>();
        
        for(Connection connection: connections){
            if(!states.containsKey(connection.from)){
                states.put(connection.from, new ZState(connection.from, connection.signalId));
            }
        }
        for(Connection connection: connections){
            states.get(connection.from).fromConnections.add(connection);
            states.get(connection.to).toConnections.add(connection);
        }
        return states;
    }