Class CompleteDistanceCalculator<U>
java.lang.Object
es.uam.eps.ir.relison.sna.metrics.distance.CompleteDistanceCalculator<U>
- Type Parameters:
U
- Type of the users.
- All Implemented Interfaces:
DistanceCalculator<U>
public class CompleteDistanceCalculator<U> extends java.lang.Object implements DistanceCalculator<U>
Computes some of the distance based metrics: distances, number of geodesic paths between two nodes, betweenness.
References:
- M.E.J. Newman. Networks: an introduction (2010)
- M.E.J. Newman, M. Girvan. Finding and Evaluating Community Structure in Networks. Physical Review E 69(2): 026113 (2004)
-
Field Summary
Fields Modifier and Type Field Description private double
asl
Average shortest path length.private java.util.Map<U,java.util.Map<U,java.lang.Double>>
distancesFrom
Distances map from u to v.private java.util.Map<U,java.util.Map<U,java.lang.Double>>
distancesTo
Distances map towards the key user.private java.util.Map<U,java.util.Map<U,java.lang.Double>>
edgeBetweenness
Edge betweenness map.private boolean
flag
Flag for detecting whether the algorithm should or should not stop.private java.util.Map<U,java.util.Map<U,java.lang.Double>>
geodesics
Number of minimum distance paths between two nodes.private Graph<U>
graph
Graph the betweenness metrics are built for.private double
infiniteDistances
Number of pairs at infinite distance to each other.private java.util.Map<U,java.lang.Double>
nodeBetweenness
Nodes betweenness map.private Communities<U>
scc
Strongly connected components. -
Constructor Summary
Constructors Constructor Description CompleteDistanceCalculator()
Constructor. -
Method Summary
Modifier and Type Method Description boolean
computeDistances(Graph<U> graph)
Computes the distances between nodes in a network.double
getASL()
Obtains the average shortest path length, averaged over all the finite distance paths.java.util.Map<U,java.util.Map<U,java.lang.Double>>
getDistances()
Returns all the distances between different pairs.double
getDistances(U orig, U dest)
Returns the distance between two nodes.java.util.Map<U,java.lang.Double>
getDistancesFrom(U node)
Return the distances between a node and the rest of nodes in the network.java.util.Map<U,java.lang.Double>
getDistancesTo(U node)
Returns the distance between the network and an specific node.java.util.Map<U,java.util.Map<U,java.lang.Double>>
getEdgeBetweenness()
Gets all the values of the edge betweenness.java.util.Map<U,java.lang.Double>
getEdgeBetweenness(U node)
Returns the edge betweenness of all the adjacent edges to a given node.double
getEdgeBetweenness(U orig, U dest)
Returns the edge betweenness of a single edge.java.util.Map<U,java.util.Map<U,java.lang.Double>>
getGeodesics()
Returns the number of geodesic paths between different pairs.java.util.Map<U,java.lang.Double>
getGeodesics(U node)
Return the number of geodesic paths between a node and the rest of nodes in the network.double
getGeodesics(U orig, U dest)
Returns the number of geodesic paths between two nodes.double
getInfiniteDistances()
Obtains the number of infinite length pairs.java.util.Map<U,java.lang.Double>
getNodeBetweenness()
Returns the node betweenness for each node in the network.double
getNodeBetweenness(U node)
Gets the value of node betweenness for a single node.Communities<U>
getSCC()
Obtains the strongly connected components of the graph.
-
Field Details
-
graph
Graph the betweenness metrics are built for. -
nodeBetweenness
Nodes betweenness map. -
edgeBetweenness
Edge betweenness map. -
distancesFrom
Distances map from u to v. -
distancesTo
Distances map towards the key user. -
geodesics
Number of minimum distance paths between two nodes. -
scc
Strongly connected components. -
flag
private boolean flagFlag for detecting whether the algorithm should or should not stop. -
asl
private double aslAverage shortest path length. -
infiniteDistances
private double infiniteDistancesNumber of pairs at infinite distance to each other.
-
-
Constructor Details
-
CompleteDistanceCalculator
public CompleteDistanceCalculator()Constructor.
-
-
Method Details
-
computeDistances
Description copied from interface:DistanceCalculator
Computes the distances between nodes in a network.- Specified by:
computeDistances
in interfaceDistanceCalculator<U>
- Parameters:
graph
- the graph.- Returns:
- true if everything went OK, false otherwise.
-
getNodeBetweenness
Description copied from interface:DistanceCalculator
Returns the node betweenness for each node in the network.- Specified by:
getNodeBetweenness
in interfaceDistanceCalculator<U>
- Returns:
- a map containing the node betweenness for each node.
-
getNodeBetweenness
Description copied from interface:DistanceCalculator
Gets the value of node betweenness for a single node.- Specified by:
getNodeBetweenness
in interfaceDistanceCalculator<U>
- Parameters:
node
- the value for the node.- Returns:
- the node betweenness for that node.
-
getEdgeBetweenness
Description copied from interface:DistanceCalculator
Gets all the values of the edge betweenness.- Specified by:
getEdgeBetweenness
in interfaceDistanceCalculator<U>
- Returns:
- the edge betweenness value for each edge.
-
getEdgeBetweenness
Description copied from interface:DistanceCalculator
Returns the edge betweenness of all the adjacent edges to a given node.- Specified by:
getEdgeBetweenness
in interfaceDistanceCalculator<U>
- Parameters:
node
- The node.- Returns:
- a map containing the values of edge betweenness for all the adjacent links to the given node.
-
getEdgeBetweenness
Description copied from interface:DistanceCalculator
Returns the edge betweenness of a single edge.- Specified by:
getEdgeBetweenness
in interfaceDistanceCalculator<U>
- Parameters:
orig
- origin node of the edge.dest
- destination node of the edge.- Returns:
- the betweenness if the edge exists, -1.0 if not.
-
getDistances
Description copied from interface:DistanceCalculator
Returns all the distances between different pairs.- Specified by:
getDistances
in interfaceDistanceCalculator<U>
- Returns:
- the distances between pairs.
-
getDistancesFrom
Description copied from interface:DistanceCalculator
Return the distances between a node and the rest of nodes in the network.- Specified by:
getDistancesFrom
in interfaceDistanceCalculator<U>
- Parameters:
node
- the node.- Returns:
- a map containing all the distances from the node to the rest of the network.
-
getDistancesTo
Description copied from interface:DistanceCalculator
Returns the distance between the network and an specific node.- Specified by:
getDistancesTo
in interfaceDistanceCalculator<U>
- Parameters:
node
- the node.- Returns:
- a map containing all the distances from each vertex in the network to the node.
-
getDistances
Description copied from interface:DistanceCalculator
Returns the distance between two nodes.- Specified by:
getDistances
in interfaceDistanceCalculator<U>
- Parameters:
orig
- origin node.dest
- destination node.- Returns:
- the distance between both nodes. if there is a path between them, +Infinity if not.
-
getGeodesics
Description copied from interface:DistanceCalculator
Returns the number of geodesic paths between different pairs.- Specified by:
getGeodesics
in interfaceDistanceCalculator<U>
- Returns:
- the distances between pairs.
-
getGeodesics
Description copied from interface:DistanceCalculator
Return the number of geodesic paths between a node and the rest of nodes in the network.- Specified by:
getGeodesics
in interfaceDistanceCalculator<U>
- Parameters:
node
- the node.- Returns:
- a map containing the number of geodesic paths from the node to the rest of the network.
-
getGeodesics
Description copied from interface:DistanceCalculator
Returns the number of geodesic paths between two nodes.- Specified by:
getGeodesics
in interfaceDistanceCalculator<U>
- Parameters:
orig
- origin node.dest
- destination node.- Returns:
- the number of geodesic paths between both nodes if there is a path between them, 0.0 if not.
-
getSCC
Description copied from interface:DistanceCalculator
Obtains the strongly connected components of the graph.- Specified by:
getSCC
in interfaceDistanceCalculator<U>
- Returns:
- the strongly connected components of the graph.
-
getASL
public double getASL()Description copied from interface:DistanceCalculator
Obtains the average shortest path length, averaged over all the finite distance paths.- Specified by:
getASL
in interfaceDistanceCalculator<U>
- Returns:
- the average shortest path length.
-
getInfiniteDistances
public double getInfiniteDistances()Description copied from interface:DistanceCalculator
Obtains the number of infinite length pairs.- Specified by:
getInfiniteDistances
in interfaceDistanceCalculator<U>
- Returns:
- the number of infinite length pairs.
-