Class Dendogram<U>

java.lang.Object
es.uam.eps.ir.relison.sna.community.Dendogram<U>
Type Parameters:
U - Type of the users.

public class Dendogram<U>
extends java.lang.Object
Abstract class that represents a dendogram and its functions.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private Graph<U> graph
    The original graph
    private FastIndex<U> index
    An index for relating the graph and the tree.
    private Tree<java.lang.Integer> tree
    The dendogram tree.
  • Constructor Summary

    Constructors 
    Constructor Description
    Dendogram​(FastIndex<U> index, Graph<U> graph, java.util.stream.Stream<org.jooq.lambda.tuple.Tuple3<java.lang.Integer,​java.lang.Integer,​java.lang.Integer>> triplets)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    java.util.Map<java.lang.Integer,​Communities<U>> getCommunitiesByNumber()
    Gets all possible community partitions by number.
    Communities<U> getCommunitiesByNumber​(int n)
    Obtains a community partition, containing, at most, a given number of communities.
    java.util.Map<java.lang.Integer,​Communities<U>> getCommunitiesBySize()
    Obtains all the possible community partitions, given the size of the communities.
    Communities<U> getCommunitiesBySize​(int size)
    Obtains a community partition, trying to provide communities with a given size.
    private Communities<U> getCommunitiesBySize​(int node, int size)
    Auxiliary recursive method.
    Tree<java.lang.Integer> getTree()
    Obtains the dendogram tree.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • index

      private final FastIndex<U> index
      An index for relating the graph and the tree.
    • graph

      private final Graph<U> graph
      The original graph
    • tree

      private final Tree<java.lang.Integer> tree
      The dendogram tree. In this tree, nodes from 0 to numNodes-1 represent the leaf nodes (i.e.: the nodes in the graph). Nodes from numNodes to 2*numNodes-2 represent the joints of the dendogram.

      Given an edge in the tree, the weight represents the number of leaves the child node is parent of.

  • Constructor Details

    • Dendogram

      public Dendogram​(FastIndex<U> index, Graph<U> graph, java.util.stream.Stream<org.jooq.lambda.tuple.Tuple3<java.lang.Integer,​java.lang.Integer,​java.lang.Integer>> triplets)
      Constructor.
      Parameters:
      index - An index for identifying nodes in the graph, and nodes in the tree.
      graph - The original graph.
      triplets - The dendogram tree. Ordered from root to leaves.
  • Method Details

    • getTree

      public Tree<java.lang.Integer> getTree()
      Obtains the dendogram tree. To prevent from modifying the original tree, this provides a copy.
      Returns:
      The dendogram tree.
    • getCommunitiesByNumber

      public Communities<U> getCommunitiesByNumber​(int n)
      Obtains a community partition, containing, at most, a given number of communities.
      Parameters:
      n - The maximum number of communities.
      Returns:
      the community partition, null if the number is invalid or something failed.
    • getCommunitiesByNumber

      public java.util.Map<java.lang.Integer,​Communities<U>> getCommunitiesByNumber()
      Gets all possible community partitions by number.
      Returns:
      A map containing all the possible partitions.
    • getCommunitiesBySize

      public Communities<U> getCommunitiesBySize​(int size)
      Obtains a community partition, trying to provide communities with a given size.
      Parameters:
      size - The maximum size of the communities.
      Returns:
      the community partition, or null if something failed.
    • getCommunitiesBySize

      private Communities<U> getCommunitiesBySize​(int node, int size)
      Auxiliary recursive method.
      Parameters:
      node - The starting node.
      size - The maximum size of the communities.
      Returns:
      the community partition, or null if something failed.
    • getCommunitiesBySize

      public java.util.Map<java.lang.Integer,​Communities<U>> getCommunitiesBySize()
      Obtains all the possible community partitions, given the size of the communities.
      Returns:
      all the possible community partitions.