Class Communities<U>
java.lang.Object
es.uam.eps.ir.relison.sna.community.Communities<U>
- Type Parameters:
U
- type of the nodes.
public class Communities<U>
extends java.lang.Object
Class that relates the nodes of a graph with communities.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Communities()
Constructor. -
Method Summary
Modifier and Type Method Description boolean
add(U user, int comm)
Adds a pair user/community.void
addCommunity()
Adds a new community to the list.java.util.stream.IntStream
getCommunities()
Obtains the different communities of the graph.int
getCommunity(U user)
Gets the community a given user belongs to.int
getCommunitySize(int community)
Obtains the size of a community.int
getNumCommunities()
Obtains the number of communities.java.util.stream.Stream<U>
getUsers(int community)
Gets the users inside a community.
-
Field Details
-
Constructor Details
-
Communities
public Communities()Constructor.
-
-
Method Details
-
getNumCommunities
public int getNumCommunities()Obtains the number of communities.- Returns:
- The number of communities.
-
getCommunities
public java.util.stream.IntStream getCommunities()Obtains the different communities of the graph.- Returns:
- an int stream containing the diferent communities of the graph.
-
getCommunity
Gets the community a given user belongs to.- Parameters:
user
- The user.- Returns:
- The community if the user exists, -1 if it does not exist.
-
getUsers
Gets the users inside a community.- Parameters:
community
- The community.- Returns:
- a stream containing the users in the community if exists, an empty stream if not.
-
addCommunity
public void addCommunity()Adds a new community to the list. -
add
Adds a pair user/community.- Parameters:
user
- The new user. It must not be already in the object.comm
- The associated community. The community has to previously exist.- Returns:
- true if everything goes OK, false if not.
-
getCommunitySize
public int getCommunitySize(int community)Obtains the size of a community.- Parameters:
community
- The community whose size we want to obtain.- Returns:
- the size of the community if it exists, 0 if it does not.
-