org.javanetworkanalyzer.alg
Class GraphSearchAlgorithm<V extends VPred,E extends EdgeSPT>

java.lang.Object
  extended by org.javanetworkanalyzer.alg.GraphSearchAlgorithm<V,E>
Type Parameters:
V - Vertices
E - Edges
All Implemented Interfaces:
TraversalAlg<V,E>
Direct Known Subclasses:
BFS, DFS, Dijkstra

public abstract class GraphSearchAlgorithm<V extends VPred,E extends EdgeSPT>
extends Object
implements TraversalAlg<V,E>

Root class for graph search algorithms, including BFS, DFS, Dijkstra, etc., and their modified versions for centrality and connectedness calculations.

Author:
Adam Gouge

Field Summary
protected  V currentStartNode
          Current start node
protected  org.jgrapht.Graph<V,E> graph
          The graph on which to calculate shortest paths.
 
Constructor Summary
GraphSearchAlgorithm(org.jgrapht.Graph<V,E> graph)
          Constructor.
 
Method Summary
protected  void init(V startNode)
          Performs any initializations to be done at the start of the TraversalAlg.calculate(V) method.
 int outdegree(V node)
          Returns the outdegree (or degree for undirected graphs) of the given node.
static Set outgoingEdgesOf(org.jgrapht.Graph g, Object node)
           
 Set<E> outgoingEdgesOf(V node)
          Returns the outgoing edges of a node for directed graphs and all edges of a node for undirected graphs.
 TraversalGraph<V,E> reconstructTraversalGraph()
          Returns the SPT (BFS/Dijkstra) or traversal graph (DFS) from the last start node TraversalAlg.calculate(V) was called on.
 List<V> successorListOf(V node)
          Returns the successor list of a node for directed graphs or the neighbor list of a node for undirected graphs.
 
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
 

Field Detail

graph

protected final org.jgrapht.Graph<V extends VPred,E extends EdgeSPT> graph
The graph on which to calculate shortest paths.


currentStartNode

protected V extends VPred currentStartNode
Current start node

Constructor Detail

GraphSearchAlgorithm

public GraphSearchAlgorithm(org.jgrapht.Graph<V,E> graph)
Constructor. The user can specify whether SPTs/traversal graphs are calculated.

Parameters:
graph - The graph
Method Detail

init

protected void init(V startNode)
Performs any initializations to be done at the start of the TraversalAlg.calculate(V) method.

Parameters:
startNode - Start node

reconstructTraversalGraph

public TraversalGraph<V,E> reconstructTraversalGraph()
Description copied from interface: TraversalAlg
Returns the SPT (BFS/Dijkstra) or traversal graph (DFS) from the last start node TraversalAlg.calculate(V) was called on. For BFS/Dijkstra, the shortest path "tree" we return may contain multiple shortest paths.

Specified by:
reconstructTraversalGraph in interface TraversalAlg<V extends VPred,E extends EdgeSPT>
Returns:
The SPT/traversal graph from the last start node TraversalAlg.calculate(V) was called on

outgoingEdgesOf

public Set<E> outgoingEdgesOf(V node)
Returns the outgoing edges of a node for directed graphs and all edges of a node for undirected graphs. Used in Dijkstra.

Parameters:
node - The node.
Returns:
The outgoing edges of the node.

outgoingEdgesOf

public static Set outgoingEdgesOf(org.jgrapht.Graph g,
                                  Object node)

successorListOf

public List<V> successorListOf(V node)
Returns the successor list of a node for directed graphs or the neighbor list of a node for undirected graphs. Used in BFS, DFS, Strahler.

Parameters:
node - The node.
Returns:
The outgoing edges of the node.

outdegree

public int outdegree(V node)
Returns the outdegree (or degree for undirected graphs) of the given node. Used in Strahler.

Parameters:
node - The node.
Returns:
The outdegree (or degree for undirected graphs) of the given node.


Copyright © 2014. All Rights Reserved.