org.javanetworkanalyzer.alg
Class DijkstraForCentrality<E extends EdgeSPT>

java.lang.Object
  extended by org.javanetworkanalyzer.alg.GraphSearchAlgorithm<V,E>
      extended by org.javanetworkanalyzer.alg.Dijkstra<VWCent,E>
          extended by org.javanetworkanalyzer.alg.DijkstraForCentrality<E>
All Implemented Interfaces:
CentralityAlg<VWCent,E,WeightedPathLengthData>, TraversalAlg<VWCent,E>

public class DijkstraForCentrality<E extends EdgeSPT>
extends Dijkstra<VWCent,E>
implements CentralityAlg<VWCent,E,WeightedPathLengthData>

An implementation of Dijkstra's algorithm which can be used to calculate betweenness and closeness in a GraphAnalyzer.

Author:
Adam Gouge

Field Summary
 
Fields inherited from class org.javanetworkanalyzer.alg.Dijkstra
TOLERANCE
 
Fields inherited from class org.javanetworkanalyzer.alg.GraphSearchAlgorithm
currentStartNode, graph
 
Constructor Summary
DijkstraForCentrality(org.jgrapht.Graph<VWCent,E> graph, Stack<VWCent> stack)
          Constructs a new DijkstraForCentrality object.
 
Method Summary
 WeightedPathLengthData getPaths()
          Returns the path length data.
protected  void init(VWCent startNode)
          Performs any initializations to be done at the start of the TraversalAlg.calculate(V) method.
protected  void multipleShortestPathUpdate(VWCent u, VWCent v, E e)
          Updates to be performed if the path to v through u is a new multiple shortest path.
protected  boolean preRelaxStep(VWCent startNode, VWCent u)
          Before relaxing the outgoing edges of u, we push it to the stack and record its shortest path length.
protected  void shortestPathSoFarUpdate(VWCent startNode, VWCent u, VWCent v, Double uvWeight, E e, PriorityQueue<VWCent> queue)
          Updates to be performed if the path to v through u is the shortest path to v found so far.
 
Methods inherited from class org.javanetworkanalyzer.alg.Dijkstra
calculate, calculate, manyToMany, manyToOne, oneToMany, oneToOne, reconstructTraversalGraph, relax
 
Methods inherited from class org.javanetworkanalyzer.alg.GraphSearchAlgorithm
outdegree, outgoingEdgesOf, outgoingEdgesOf, reconstructTraversalGraph, successorListOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.javanetworkanalyzer.alg.TraversalAlg
calculate, reconstructTraversalGraph
 

Constructor Detail

DijkstraForCentrality

public DijkstraForCentrality(org.jgrapht.Graph<VWCent,E> graph,
                             Stack<VWCent> stack)
Constructs a new DijkstraForCentrality object.

Parameters:
graph - The graph.
stack - The stack which will return nodes ordered by non-increasing distance from startNode.
Method Detail

init

protected void init(VWCent startNode)
Description copied from class: GraphSearchAlgorithm
Performs any initializations to be done at the start of the TraversalAlg.calculate(V) method.

Overrides:
init in class Dijkstra<VWCent,E extends EdgeSPT>
Parameters:
startNode - Start node

preRelaxStep

protected boolean preRelaxStep(VWCent startNode,
                               VWCent u)
Before relaxing the outgoing edges of u, we push it to the stack and record its shortest path length.

Overrides:
preRelaxStep in class Dijkstra<VWCent,E extends EdgeSPT>
Parameters:
u - Vertex u.
Returns:
true if we should stop the Dijkstra search.

shortestPathSoFarUpdate

protected void shortestPathSoFarUpdate(VWCent startNode,
                                       VWCent u,
                                       VWCent v,
                                       Double uvWeight,
                                       E e,
                                       PriorityQueue<VWCent> queue)
Description copied from class: Dijkstra
Updates to be performed if the path to v through u is the shortest path to v found so far.

Overrides:
shortestPathSoFarUpdate in class Dijkstra<VWCent,E extends EdgeSPT>
u - Vertex u
v - Vertex v
uvWeight - w(u,v)
e - Edge e
queue - Queue

multipleShortestPathUpdate

protected void multipleShortestPathUpdate(VWCent u,
                                          VWCent v,
                                          E e)
Description copied from class: Dijkstra
Updates to be performed if the path to v through u is a new multiple shortest path. There is no need to set the distance on v since this is a multiple shortest path.

Overrides:
multipleShortestPathUpdate in class Dijkstra<VWCent,E extends EdgeSPT>
Parameters:
u - Vertex u
v - Vertex v
e - Edge e

getPaths

public WeightedPathLengthData getPaths()
Description copied from interface: CentralityAlg
Returns the path length data.

Specified by:
getPaths in interface CentralityAlg<VWCent,E extends EdgeSPT,WeightedPathLengthData>
Returns:
The path length data


Copyright © 2014. All Rights Reserved.