Class EdgeBetweenness<U>

java.lang.Object
es.uam.eps.ir.relison.sna.metrics.distance.pair.EdgeBetweenness<U>
Type Parameters:
U - Type of the users.
All Implemented Interfaces:
PairMetric<U>

public class EdgeBetweenness<U>
extends java.lang.Object
implements PairMetric<U>
Computes the edge betweenness of the graph.

Reference: M.E.J. Newman, M. Girvan. Finding and evaluating community structure in networks. Physical Review E 69(2), pp. 1-16 (2004)

  • Field Summary

    Fields 
    Modifier and Type Field Description
    private DistanceCalculator<U> dc
    Distance calculator.
    private boolean normalize
    Indicates whether the betweenness has to be normalized or not.
  • Constructor Summary

    Constructors 
    Constructor Description
    EdgeBetweenness​(boolean normalize)
    Constructor.
    EdgeBetweenness​(DistanceCalculator<U> dc, boolean normalize)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    double averageValue​(Graph<U> graph)
    Computes the average value of the metric
    double averageValue​(Graph<U> graph, java.util.stream.Stream<Pair<U>> edges, int edgeCount)
    Computes the average value of a certain group of pairs.
    double averageValueOnlyLinks​(Graph<U> graph)
    Computes the average value of the metric, restricted to the set of links in the network.
    java.util.Map<Pair<U>,​java.lang.Double> compute​(Graph<U> graph)
    Computes the value of the metric for all the possible pairs in the graph.
    java.util.Map<Pair<U>,​java.lang.Double> compute​(Graph<U> graph, java.util.stream.Stream<Pair<U>> edges)
    Computes the value of the metric for a selection of pairs in the graph.
    double compute​(Graph<U> graph, U orig, U dest)
    Computes the value of the metric for a single pair of nodes
    java.util.function.Function<U,​java.lang.Double> computeDest​(Graph<U> graph, U dest)
    Given a user, computes the value of a metric for all the possible pairs in the graph where the user is the destination.
    java.util.Map<Pair<U>,​java.lang.Double> computeOnlyLinks​(Graph<U> graph)
    Computes the value of the metric for all the links in the graph.
    java.util.function.Function<U,​java.lang.Double> computeOrig​(Graph<U> graph, U orig)
    Given a user, computes the value of a metric for all the possible pairs in the graph where the user is the origin.

    Methods inherited from class java.lang.Object

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

    • dc

      private final DistanceCalculator<U> dc
      Distance calculator.
    • normalize

      private final boolean normalize
      Indicates whether the betweenness has to be normalized or not.
  • Constructor Details

    • EdgeBetweenness

      public EdgeBetweenness​(DistanceCalculator<U> dc, boolean normalize)
      Constructor.
      Parameters:
      dc - distance calculator.
      normalize - true if we have to normalize the betweenness, false otherwise.
    • EdgeBetweenness

      public EdgeBetweenness​(boolean normalize)
      Constructor.
      Parameters:
      normalize - true if we have to normalize the betweenness, false otherwise.
  • Method Details

    • compute

      public double compute​(Graph<U> graph, U orig, U dest)
      Description copied from interface: PairMetric
      Computes the value of the metric for a single pair of nodes
      Specified by:
      compute in interface PairMetric<U>
      Parameters:
      graph - The full graph.
      orig - The origin node of the edge.
      dest - The destiny node of the edge.
      Returns:
      The value of the metric for that edge.
    • compute

      public java.util.Map<Pair<U>,​java.lang.Double> compute​(Graph<U> graph, java.util.stream.Stream<Pair<U>> edges)
      Description copied from interface: PairMetric
      Computes the value of the metric for a selection of pairs in the graph.
      Specified by:
      compute in interface PairMetric<U>
      Parameters:
      graph - The full graph.
      edges - A stream containing the selected pairs.
      Returns:
      A map containing the metrics for each pair in the stream that exists.
    • computeOrig

      public java.util.function.Function<U,​java.lang.Double> computeOrig​(Graph<U> graph, U orig)
      Description copied from interface: PairMetric
      Given a user, computes the value of a metric for all the possible pairs in the graph where the user is the origin. As, for efficiency methods, all values might not be computed, the default value of the metric shall be retrieved from the outcome.
      Specified by:
      computeOrig in interface PairMetric<U>
      Parameters:
      graph - the graph.
      orig - the origin node.
      Returns:
      the map containing the values of the metric.
    • computeDest

      public java.util.function.Function<U,​java.lang.Double> computeDest​(Graph<U> graph, U dest)
      Description copied from interface: PairMetric
      Given a user, computes the value of a metric for all the possible pairs in the graph where the user is the destination. As, for efficiency methods, all values might not be computed, the default value of the metric shall be retrieved from the outcome.
      Specified by:
      computeDest in interface PairMetric<U>
      Parameters:
      graph - the graph.
      dest - the origin node.
      Returns:
      the map containing the values of the metric.
    • compute

      public java.util.Map<Pair<U>,​java.lang.Double> compute​(Graph<U> graph)
      Description copied from interface: PairMetric
      Computes the value of the metric for all the possible pairs in the graph.
      Specified by:
      compute in interface PairMetric<U>
      Parameters:
      graph - The full graph.
      Returns:
      A map containing the metrics for each node.
    • computeOnlyLinks

      public java.util.Map<Pair<U>,​java.lang.Double> computeOnlyLinks​(Graph<U> graph)
      Description copied from interface: PairMetric
      Computes the value of the metric for all the links in the graph.
      Specified by:
      computeOnlyLinks in interface PairMetric<U>
      Parameters:
      graph - the full graph.
      Returns:
      A map containing the metrics for each link.
    • averageValue

      public double averageValue​(Graph<U> graph)
      Description copied from interface: PairMetric
      Computes the average value of the metric
      Specified by:
      averageValue in interface PairMetric<U>
      Parameters:
      graph - The full graph.
      Returns:
      The average value of the metric
    • averageValueOnlyLinks

      public double averageValueOnlyLinks​(Graph<U> graph)
      Description copied from interface: PairMetric
      Computes the average value of the metric, restricted to the set of links in the network.
      Specified by:
      averageValueOnlyLinks in interface PairMetric<U>
      Parameters:
      graph - the network.
      Returns:
      the average value of the metric over the links in the network.
    • averageValue

      public double averageValue​(Graph<U> graph, java.util.stream.Stream<Pair<U>> edges, int edgeCount)
      Description copied from interface: PairMetric
      Computes the average value of a certain group of pairs.
      Specified by:
      averageValue in interface PairMetric<U>
      Parameters:
      graph - the full graph.
      edges - a stream containing the selected pairs.
      edgeCount - the number of pairs in the stream.
      Returns:
      The average value of the metric for those pairs.