Community Exploration: From Offline Optimization to Online Learning