This works really well with Neo4j Bloom and will show you whether you're on the right track.
1/
CALL algo.louvain.stream('User', 'FRIENDS')
YIELD nodeId, community
WITH community, collect(nodeId) AS ids
CALL apoc.create.vNode(['Community'], { name: community })
YIELD node AS communityNode
UNWIND ids AS nodeId
MATCH (user) where id(user) = nodeId
CALL apoc.create.vRelationship(user, 'BELONGS_TO', {}, communityNode) YIELD rel
// Return the nodes and relationships
RETURN communityNode, user, rel